When changing a video's thumbnail to a different thumbnail, the old thumbnail is not deleted from the file system. Also, when deleting a video, the video and all thumbs related to that video are deleted from the file system BUT, all the thumbnails remain in the "files" table. They should be deleted also.

thanks

Comments

ericpai’s picture

I fixed both issues. It may not be pretty, but I needed it to work now.
In video.module:
For the deleting of the old thumbnail in function video_upload_manual_thumb(&$element):

  // Remove old image (if any) & clean up database.
  // $old_thumb = $element['data']['video_thumb']['#value']; // -- this value was always empty
  $old_thumb = $element['#default_value']['data']['video_thumb']; // ++ this contains the file path
  if (!empty($old_thumb)) {
  	
    if (file_delete($old_thumb)) {
      //db_query('DELETE FROM {files} WHERE filepath=%d', $old_thumb); // not looking for an id 
      db_query('DELETE FROM {files} WHERE filepath="%s"', $old_thumb); // looking for file path
    }
  }

For deleting the thumbnails when deleting the video in function video_file_delete($file), Just above video_module_invoke('delete', $file); I added these lines:

$thumbnailFile=$file->data['video_thumb'];
	if (!empty($thumbnailFile)) {
	  db_query('DELETE FROM {files} WHERE filepath="%s"', $thumbnailFile);
	}
Jorrit’s picture

Status: Active » Fixed

I have committed a fix for this problem to the 6.x-4.x branch. Deleting the file record when the thumbnail was replaced was already fixed, I added deleting the file from the table when deleting the video. I remove all files within the thumbnail directory from the files table using a LIKE statement. This will also delete old file records that were left over because of this bug.

Jorrit’s picture

This fix has been released in Video 6.x-4.3-rc1. Please take a look and test the release candidate.

Status: Fixed » Closed (fixed)
Issue tags: -thumbnails deleted

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