Problem: When images are created they are stored in:
./files/images
./files/images/temp

When I delete the image node, those in ./files/images are removed but not those in ./files/images/temp.

This results in 'residue' which waste space. Probably a particularly unpleasant situation for those people who are with hosters that don't allow access. And... If I upload another image with the same name, there is a smart mechanism in place that appends a _N to the file. Great. Except those dead files in temp are considered for counting up. So the newly uploaded file will get an _0 even though its the first one in the system.

Suggestion:
clean up temp when finished with it. Stay clutter free :)
Remove the files after (I guess) the conversions are done.
Or, an administrative option to clean out the temp folder

Img_assist settings ($Revision: 1.43.2.11 $), drupal 4.6.2
btw - _really_ cool that the revision is shown in admin/setting!! I wished others would follow suite.

greetings,
Martin
PS: sorry if i missed it, but I did not see a similar issue report.

Comments

Robrecht Jacques’s picture

The files in /files/images/temp are removed every once in a while by the cron system. See: http://drupal.org/node/260 (point 6. CRON TASKS).

If you don't have access to a crontab (either on the hosting or by any other means), you could use "poor mans cron": http://drupal.org/project/poormanscron.

So I think this is "by design", but I'll leave the issue "active" for the moment.

killes@www.drop.org’s picture

Status: Active » Closed (works as designed)

I am not that shy. :)

MartinA-1’s picture

Hm, Gerhard, looking at your posting and envolvement history you certainly are not shy :)

Point taken. Though I always though 'If you start a job, you finish it'. And I'd think cleaning up afterwards and not leaving the mess for someone else is part of that. Then again I'm just a humble user and admin and whose programming days are long over ;)

Thanks anyhow,
Martin

MartinA-1’s picture

Status: Closed (works as designed) » Active

I'm going to be unshy and reopen this one. However, maybe the category is wrong.

The temp files do not get deleted in: ./files/images/temp

Attempted:

- running cron hourly, called manually which creates a log/watchdog entry of success in drupal. Beyond that I can see other things cron is doing, so it is working
- running poormanscron, again the log entries stating success are there
- calling /cron.php manually. again...

I have full access to the server: slackware 10.1.

walkah’s picture

Status: Active » Closed (works as designed)

the images are cleared by cron - on the first cron run after 6 hours:

function image_cron() {
  $path = variable_get('image_default_path', 'images') . '/temp';
  $files = file_scan_directory(file_create_path($path), '.*');
  foreach ($files as $file => $info) {
    if (time() - filemtime($file) > 60*60*6) {
      file_delete($file);
    }
  }
}

it's absolutely by design , and verified working.

MartinA-1’s picture

Thanks walkah,

This information now given puts a further undocumented (?) variable into the issue: the 6 hours beyond file modification time. I was led to believe by the documentation running cron deletes the files. Right there and then. The time configurable for poormanscron would thereby determine how often the files are deleted. Similarly how I configure cron. I start a programme, something happens.

Yes, I can confirm by now the files are gone. So, I guess, the documentation needs clarification. And ideally that parameter would be admin configurable...

Sorry to be a pain :) But I do try to avoid looking at code if I am doing admin and especially content work.

jpsalter’s picture

Version: » 4.6.x-1.x-dev

You can easily change the code to get the desired effect (ie. clean out the temp folder after the image is imported) by changing the function "file_copy" to "file_move" in the _image_insert function found in image.module.

Warning: I've tested this out and it works for me. But, I could be breaking something else and haven't found it.

Replacement code:

/**
 * Moves temporary (working) images to the final directory and stores
 * relevant information in the files table
 */
function _image_insert($nid, $label, $image) {
  $dest = _image_filename(basename($image));
  if (file_move($image, $dest)) {
    $info = image_get_info(file_create_path($dest));
    $file->filename = $label;
    $file->filepath = _image_filename(basename($image));
    $file->filemime = $info['mime_type'];
    $file->filesize = filesize(file_create_path($dest));
    $fid = db_next_id('{files}_fid');
    db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize, list) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d)",
             $fid, $nid, $file->filename, $file->filepath, $file->filemime, $file->filesize, 0);
  }
}