function _flashnode_delete_file_if_no_longer_needed in Flash Node 6.3
Same name and namespace in other branches
- 6.2 flashnode.module \_flashnode_delete_file_if_no_longer_needed()
Helper function: Remove a flash file from the file table and file system if it is no longer needed as a result of revision deletion or update
2 calls to _flashnode_delete_file_if_no_longer_needed()
- flashnode_delete_revision in ./
flashnode.module - Delete a flashnode revision
- flashnode_update in ./
flashnode.module - Implementation of hook_update
File
- ./
flashnode.module, line 958
Code
function _flashnode_delete_file_if_no_longer_needed($fid) {
// Check how many times the file is listed in {flashnode}
$result = db_result(db_query("SELECT COUNT(fid) FROM {flashnode} WHERE fid = %d", $fid));
// If only one occurrence then it is no longer needed because this revision is
// about to be deleted, or this revision is about to get a new upload
if ($result == 1) {
// Get the file path from the files table
$filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
// Delete from the file system and {files}
db_query("DELETE FROM {files} WHERE fid = %d", $fid);
file_delete($filepath);
}
}