Download & Extend

Files overwriting each other on import

Project:Migrate
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:mikeryan
Status:closed (fixed)

Issue Summary

We've noticed files overwriting themselves on migration. If you're importing two files, one named a/1.jpg and another named b/1.jpg, the basename() for both these are 1.jpg even though they are different files in different directories. I'm wondering if in plugins/destinations/fields.inc+190, if we should (a) just pass the $full_path to file_stream_wrapper_uri_normalize() or (b) further make the name unique by changing basename($full_path) to str_replace('/', '-', $full_path). Is this the right place to fix the problem and if so, which solution do you like?

Comments

#1

I've fiddled with this code a lot trying to make all the file_move, file_copy, and file_save cases work properly. chx just changed it some more. At this point, I'm not quite sure whats needed. We need some tests here for sure. At first blush, that str_replace looks good.

#2

Moshe - not fully vetted but am seeing properly created nodes and images that were once dupes overwriting each other now creating new fids. Will do a few more tests but so far looks good. Was a significant issue so hope this is a good fix. Would appreciate a review for any gotchas we may be missing.

#3

Project:Migrate» Migrate Extras
Version:7.x-2.x-dev» 7.x-2.x-dev
Component:Code» Filefield
Status:needs review» active

Filefield handling has moved to Migrate Extras, and has changed a bit since the move.

#4

Status:active» needs review

Sorry, I thought I uploaded a patch with this...

AttachmentSize
migrate-fields.patch 787 bytes

#5

Project:Migrate Extras» Migrate
Version:7.x-2.x-dev» 7.x-2.x-dev
Component:Filefield» Code
Assigned to:Anonymous» mikeryan

It moved back to Migrate a while ago.

#6

Status:needs review» fixed

Committed, thanks!

#7

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here