uploads: don't clean up replaced files too early.

Don't try delete files belonging to completed uploads during pruning. If
an uploaded post was replaced shortly after upload, then the original
file could get deleted during pruning since it's no longer in use, but
this isn't supposed to happen until the replacement grace period (30
days) is over.
This commit is contained in:
evazion
2019-09-04 14:49:52 -05:00
parent 1b426fb23f
commit 0ec36785f0
2 changed files with 18 additions and 1 deletions

View File

@@ -101,7 +101,7 @@ class Upload < ApplicationRecord
def delete_files
# md5 is blank if the upload errored out before downloading the file.
if md5.blank? || Upload.where(md5: md5).exists? || Post.where(md5: md5).exists?
if is_completed? || md5.blank? || Upload.where(md5: md5).exists? || Post.where(md5: md5).exists?
return
end