When the Private upload module makes files private and moves them from /files to /files/private it replaces any existing files with the same filenames thus potentially deleting someone else's files and giving them access to your files instead. This is not ideal and it is also contradictory to the default behavior of the Upload module - which renames new files with duplicate filenames - causing extra confusion for the developer as to what is going on. It would be good if there was a setting where admin could choose if private files with duplicate filenames should replace the original files or be renamed.
Petter
Comment | File | Size | Author |
---|---|---|---|
#4 | private_upload.patch | 5.36 KB | Anonymous (not verified) |
#1 | private_upload.module.patch | 3.86 KB | acrollet |
Comments
Comment #1
acrollet CreditAttribution: acrollet commentedI'm attaching a patch to fix this issue - it uses the default drupal behavior of appending an incremented digit to duplicate filenames. It would be easy to make a preference for this behavior, but my contention is that this patch produces the the correct behavior, as it avoids database inconsistency. (producing messages like this: There are '29' files in the private folder, and the DB thinks there are '116' private files.)
Comment #2
acrollet CreditAttribution: acrollet commentedI'm attaching a patch to fix this issue - it uses the default drupal behavior of appending an incremented digit to duplicate filenames. It would be easy to make a preference for this behavior, but my contention is that this patch produces the the correct behavior, as it avoids database inconsistency. (producing messages like this: There are '29' files in the private folder, and the DB thinks there are '116' private files.)
Comment #3
Jody LynnSee also #371492: Upload a file with the same name doesn't remove the old upload. Same bug exists in D6. It can cause loss of files, incorrect file served, and corrupt (truncated by wrong filesize) files served.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedattached is a patch for the 6 branch.
Comment #5
Jody LynnReviewed and tested Justin's patch.
As well as patching the module you may need to do some manual cleanup of your files if they were affected by this. A few of the things I did to generate lists of files needing cleanup:
The bug could result in having missing files or files that were overwritten with a different file. This will print out files that do not match their filesize in the database, either because they are missing or because they were overwritten with a different file:
Sql query to list filepaths that are in the files and upload table more than once.
Comment #6
Jody LynnFixed in the D6 dev branch. Still an issue for D5. The patch in comment 1 needs review and testing or the patch in #4 needs porting.