I've tried this on a sandbox site and it works fine, but I've got an existing site that I've been working over the last few months and this happens:

-Create new node and upload a file via the file field.
-Edit the node and click "remove".
-File is no longer associated with the node, but still resides in the files directory and in the "files" table with a status of "1".

I was thinking that maybe I had a conflicting module or something wrong with my file permissions, but even after digging into these two possibilities, I haven't come up with any leads. Can anyone offer any other ideas of what I might be doing wrong, please?

Comments

attheshow’s picture

Title: Files Deleted When Clicking Remove - Only 1 Site » Files Not Deleted When Node Revisions Turned On

Figured it out. Files aren't deleted when node revisions are turned on for your content type. This appears to be intentional (see #370531: Properly Handle Revisions for document control), but my users and I found this to be very confusing since we don't do "reverts" often at all. We do, however, need to remove old files all the time.

My patch for this on my local system was to remove from filefield_field.inc the line that says:
if ($node->is_new || !empty($node->revision) || !empty($node->skip_filefield_delete)) {

and replace it with

if ($node->is_new || !empty($node->skip_filefield_delete)) {

I hope this helps others.

quicksketch’s picture

Status: Active » Closed (works as designed)

This is intentional behavior, as noted.