Closed (fixed)
Project:
FileField
Version:
6.x-3.7
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
9 Jun 2011 at 20:55 UTC
Updated:
27 Jun 2011 at 16:21 UTC
I've found that when I remove a filefield / imagefield file from a node, that it is also getting deleted in the underlying filesystem. I'm assuming this is by design. My question -- is it possible to disable this somehow? My site maintains a library of images that may be used in the future even if they are no longer currently associated with a node. The preferred behavior for us is that a file is not deleted from the filesystem when it is removed, even if it is no longer associated with any node.
Comments
Comment #1
ISPTraderChris commentedI did a little digging this morning on this, and basically a call to file_field_delete() is made to delete any unreferenced files when a file is removed from a node. This function in turns invokes hook_field_references() to allow all active modules the chance to report that the file is currently referenced.
I suspect that for most this won't be an issue, as any module you are using to upload and manage your files (e.g. IMCE) also is reporting that your files are referenced and should not be deleted. However, in my case I am dealing with a legacy image library that was imported manually (ftp).
My fix for this was to implement the following code in a custom module: