Download & Extend

potential filename collision if files stored on s3 and deleted on local server

Project:Media Mover
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I have a configuration that uploads files to s3. Suppose I opt to "delete source from local server" after file is stored on s3.

If a second file is uploaded with same name ('abc.flv') as a previously uploaded file, then this second file does not get renamed to 'abc_0.flv' (because 'abc.flv' no longer resides on the local server), and media_mover does not process this second file.

To fix the problem, I modified mm_s3_send() so that rather than deleting the source-file, it replaces the source-file with a 0-byte file. This way, when the second file is uploaded, it gets renamed to 'abc_0.flv'.

function mm_s3_send($file, $configuration, $verb, $action_id) {
   ...
   foreach (array_unique($delete_files) as $delete_file) {
      watchdog('MM S3', 'Deleted local file: !file', array('!file' => $delete_file));
      unlink($delete_file);
      touch($delete_file); // <--- this is the line I added
    }
}
AttachmentSizeStatusTest resultOperations
mm_s3.bug21.diff38 bytesIgnored: Check issue status.NoneNone