I've had some issue with the node_clone module. Specifically, when I clone a node that has an imagefield, new entries are created in the files table, which point to the same file name as the original node. This works fine, but then when I delete either the original or the clone, the file is deleted from the files/ directory too. This leaves the remaining clone missing it's image files.

I've added a few lines of code to _imagefield_file_delete() that check if there are other nodes that still reference the file, and if there are, we skip calling file_delete() for the file, and leave it for the others. If there are no remaining references, the file is deleted as normal.

I'm using filefield 5.x-1.2-rc1, but this patch should port easily to newer releases. I looked at the code, and it seems very similar.

This is one of my first patches. Hope I'm doing this right, and it's useful to someone!

CommentFileSizeAuthor
#1 imagefield-clone-fix.patch1017 bytespsuda

Comments

psuda’s picture

StatusFileSize
new1017 bytes

attaching patch file to this comment

dopry’s picture

Status: Needs review » Closed (fixed)

imagefield 1.x is no longer supported.