uploads: don't delete files of abandoned uploads.
Just leave them. They don't take up that much space and they may be used in the future if someone else tries to upload the same file.
This commit is contained in:
@@ -75,8 +75,6 @@ class Upload < ApplicationRecord
|
||||
validates_with FileValidator, on: :file
|
||||
serialize :context, JSON
|
||||
|
||||
after_destroy_commit :delete_files
|
||||
|
||||
scope :pending, -> { where(status: "pending") }
|
||||
scope :preprocessed, -> { where(status: "preprocessed") }
|
||||
scope :completed, -> { where(status: "completed") }
|
||||
@@ -104,19 +102,6 @@ class Upload < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
concerning :FileMethods do
|
||||
def delete_files
|
||||
# md5 is blank if the upload errored out before downloading the file.
|
||||
if is_completed? || md5.blank? || Upload.exists?(md5: md5) || Post.exists?(md5: md5)
|
||||
return
|
||||
end
|
||||
|
||||
media_asset&.destroy!
|
||||
media_asset&.delete_files!
|
||||
DanbooruLogger.info("Uploads: Deleting files for upload md5=#{md5}")
|
||||
end
|
||||
end
|
||||
|
||||
concerning :StatusMethods do
|
||||
def is_pending?
|
||||
status == "pending"
|
||||
|
||||
Reference in New Issue
Block a user