Admin thumbnail files is not deleted when image is removed in the node (imagefield_file_delete is never fired), they are however deleted when the entire node is deleted.

CommentFileSizeAuthor
#26 filefield_field_replace-6.x-3.x-dev.patch705 bytesdagmar

Comments

drewish’s picture

Title: Admin thumbnail files is not deleted when image is removed in the node » Files are not deleted when replaced
Project: ImageField » FileField

I traced nonsie's issue back to field_file_save()... it doesn't know that a file is a replacement so it can't call field_file_delete() which would take care of removing the admin image.

dopry’s picture

Status: Active » Closed (works as designed)

because the file is removed from the node not, deleted. this will change before release but is how it works currently.

drewish’s picture

Status: Closed (works as designed) » Active
dopry’s picture

Priority: Normal » Critical

This is a beta blocker. Need to track removed files in form_state and on #submit field_file_delete them.

drewish’s picture

klaus66’s picture

Hello,

i don't understand what beta blocker mean.

Can you explain that.

Thank you.

Klaus

klaus66’s picture

Hello,

I see there is now an alpha4.

My question is now when it is planed that the "file delete problem" will be fixed.

I think on a production site where users can upload files and remove them it is not possible to work with this module at the moment.

best regards

Klaus

drewish’s picture

ellanylea’s picture

Files still not deleted when replaced in 6.x-3.0-alpha5. Would be happy to test patch if any.

ipto’s picture

Version: 6.x-3.x-dev » 6.x-3.0-alpha5

When i press delete button in edit node page and press save image dont't show in node view, but in BD table=files deleted files status=1 (active, used). This is not possible to remove unused files.

dopry’s picture

yep file delete's aren't happening yet.. It's sorta by design.. I meant to have a filebrowser in place by now.. but haven't gotten around to it.. I'll get the delete functionality in fairly soon I think..

drewish’s picture

marked #318044: Files are not deleted as a duplicate

drewish’s picture

Version: 6.x-3.0-alpha5 » 6.x-3.x-dev
drewish’s picture

adaven’s picture

subscribing

ilfelice’s picture

Subscribing

trevorsheridan’s picture

This summer I amended either this module for D5 or the Image Attach (can't remember which) to do what we need done here. I am wondering if there is any work already being done on this or if I should just go ahead and do it this weekend? (If so I will create it for D6 and if I did create it this summer for this module already I will provide what I did for D5 as well. Thoughts?

Trevor

mfb’s picture

[subscribing]

gábor hojtsy’s picture

Issue tags: +drupal.org upgrade

Andrew Morton says this bug is vital for drupal.org to start get using FileField / ImageField.

ddauer’s picture

subscribing

drewish’s picture

akael’s picture

Any update on this bug?

gábor hojtsy’s picture

Issue tags: -drupal.org upgrade

Not applicable to upgrade, since we found that keeping image module for now works once we fixed its upgrade path.

smithn.nc’s picture

Subscribing.

dopry’s picture

Status: Active » Fixed

fixed in HEAD.

dagmar’s picture

Status: Fixed » Needs work
StatusFileSize
new705 bytes

Hello dopry:

I have tested filefield 6.x-3.x-dev and I'm think that this issue is not completly solved.

First, when I create a new node, files uploaded with filefield are not attached to the nodes, and php displays an invalid foreach() warning.

I have created a small patch that solves this bug, but there is another problem.

When users replace a file without submit the node (the first time), files are not deleted.

For example:

go to: node/add/page
upload a field with filefiled.
replace this file with another one
submit the node

The first file is still in the table {files} and in the disk.

I have marked my pacth as (code need work) because it doesn't solve the second issue.

markus_petrux’s picture

hmm... but that file would exist marked as temporary in the files table, and that's expired by system_cron(), AFAICT.

dagmar’s picture

Status: Needs work » Needs review

I did not know of this characteristic. I see that was introduced in Drupal 6.

Well in this case, I'm think that the last patch will be enought to solve the issue.

Changing status.

dopry’s picture

Status: Needs review » Fixed

committed to HEAD with modifications.

philsward’s picture

Even on a cron run using the 6.x-3.x-dev (2009-Feb-06) version, I am still seeing files on the server if a file is added, removed, another added and then the node is saved... http://drupal.org/node/369450

dagmar’s picture

This is how system_cron() works

function system_cron() {
  // Cleanup the flood.
  db_query('DELETE FROM {flood} WHERE timestamp < %d', time() - 3600);
  // Cleanup the batch table.
  db_query('DELETE FROM {batch} WHERE timestamp < %d', time() - 864000);

  // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
  $result = db_query('SELECT * FROM {files} WHERE status = %d and timestamp < %d', FILE_STATUS_TEMPORARY, time() - DRUPAL_MAXIMUM_TEMP_FILE_AGE);
  while ($file = db_fetch_object($result)) {
    if (file_exists($file->filepath)) {
      // If files that exist cannot be deleted, continue so the database remains
      // consistent.
      if (!file_delete($file->filepath)) {
        watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->filepath), 'error');
        continue;
      }
    }
    db_query('DELETE FROM {files} WHERE fid = %d', $file->fid);
  }
  $core = array('cache', 'cache_block', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
  $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
  foreach ($cache_tables as $table) {
    cache_clear_all(NULL, $table);
  }
}

DRUPAL_MAXIMUM_TEMP_FILE_AGE in seconds is:

define('DRUPAL_MAXIMUM_TEMP_FILE_AGE', 21600);

Then, you have to wait at least 6 hours to delete a file with system_cron()

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.