summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/upload/upload.module8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 3bcdf5ee4..becab2228 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -391,6 +391,14 @@ function upload_save(&$node) {
// will be required.
if (!empty($file->remove)) {
db_query('DELETE FROM {upload} WHERE fid = %d AND vid = %d', $fid, $node->vid);
+
+ // If the file isn't used by any other revisions delete it.
+ $count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $fid));
+ if ($count < 1) {
+ file_delete($file->filepath);
+ db_query('DELETE FROM {files} WHERE fid = %d', $fid);
+ }
+
// Remove it from the session in the case of new uploads,
// that you want to disassociate before node submission.
unset($_SESSION['upload_files'][$fid]);