field_file_save_file($temp_filepath, array(), $filepath, FILE_EXISTS_REPLACE); creates a duplicate records in {files}.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | filefield_replace_1.patch | 1.38 KB | amitaibu |
| Snap1.png | 7.89 KB | amitaibu |
field_file_save_file($temp_filepath, array(), $filepath, FILE_EXISTS_REPLACE); creates a duplicate records in {files}.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | filefield_replace_1.patch | 1.38 KB | amitaibu |
| Snap1.png | 7.89 KB | amitaibu |
Comments
Comment #1
dopry commentedDoes it also create a duplicate copy of the file in the files folder?
Comment #2
amitaibuNo, it doesn't create a duplicate file (
FILE_EXISTS_REPLACE).Comment #3
dopry commentedhmm..well that is dirty... I guess we should correct it a some point.. do you have time to write a patch?
Comment #4
amitaibuI'd love to help. Can you point me in the right direction, i.e. how you would like it to be fixed.
[EDIT]: I've started working on a patch, i'll roll soon.
Comment #5
amitaibuAttached file makes sure that when FILE_EXISTS_REPLACE is used file isn't renamed and if a database record already exists it is updated.
Comment #6
drewish commentedWell this ties in nicely with a core issue: #334303: Handling overwriting of managed files (with unittests!). You reminded me that file_save_upload() also need to take replacement into account. That said I'm not sure we should be replacing a permanent fid with a temporary one...
Comment #7
dopry commentedupping to critical to keep it on my radar.
Comment #8
dopry commentedjust to make my life easier since this stuff is intended for filefield only... I removed the replace option all together... delete then update if you need to path to be saved correctly...
This also applies to field_file_save_upload.