During migration D6->D7 I get an error message "Integrity constraint violation" I use Migrate and Migrate_D2D in my process of migrating from D6 into D7 and I get this message for each an every node when using "MigrateFileUri": 

    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'public://instrument/instrumentbilder/63379742-s_1.jpg' for key 'uri': INSERT INTO {file_managed} (uid, filename, uri … and so on…


The strange thing is that on another computer with the same development environment (WAMP) most of the nodes are imported without problem with exactly the same code. Something must be different though… Some mysql setting in WAMP maybe?

I have searched for the "duplicate files" in the table "file_managed" and I can confirm that these files are not present in that table. So the duplication must happen during the import. For some reason the node must be saved twice?

I should mention that when importing all files in a separate migration and using MigrateFileFid as file class, there is no problem. The thing is that I need to use urlencode to clean file names and also I want to decide where different files from different node types are to be saved (different destination_dir for different file types), and as far as I understand those options are not available with MigrateFilFid.
The error message indicates that your underlying database is having a problem. It looks like you've tried the migration multiple times, and that parts of it were successful previously. What the error message is stating is that you are attempting to insert duplicate records into the database, or at least duplicate keys for an existing record. You need to reset/empty the NEW database prior to running migrate and migrate_d2d to remove the problem.