function video_file_delete in Video 6.4
Same name and namespace in other branches
- 6.5 video.module \video_file_delete()
- 7.2 video.module \video_file_delete()
- 7 video.module \video_file_delete()
Implementation of hook_file_delete().
File
- ./
video.module, line 328 - video.module
Code
function video_file_delete($file) {
if (empty($file->fid)) {
watchdog('video', 'video_file_delete called with empty argument', array(), WATCHDOG_ERROR);
return;
}
// TODO: only execute this method if the file was uploaded by this module.
// Let other modules to know about the file delete
// before we delete the file, so the module has access to information in the database.
video_module_invoke('delete', $file);
// @TODO : check for enable trancoder
// delete the transcoder job
module_load_include('inc', 'video', '/includes/transcoder');
$transcoder = new video_transcoder();
$transcoder
->delete_job($file);
// TODO: Move this to the file system class
// Now lets delete our video thumbnails and folder.
$video_thumb_path = variable_get('video_thumb_path', 'video_thumbs');
$thumb_folder = file_directory_path() . '/' . $video_thumb_path . '/' . $file->fid . '/';
// Recursively delete our folder and files.
if (is_dir($thumb_folder)) {
rmdirr($thumb_folder);
// Delete any entries in the files table that may refer to the above path.
// TODO: this is a slow query
db_query('DELETE FROM {files} WHERE filepath LIKE "%b%%"', strtr(db_escape_string($thumb_folder), array(
'%' => '\\%',
'_' => '\\_',
)));
}
}