replacements: don't delete replaced files.

Don't delete replaced files after 30 days. There are only about 30k
replacements in total, so the cost of keeping replaced files is
negligible. It was also wrong because the media asset wasn't destroyed
too, so there were active media assets with missing files.
This commit is contained in:
evazion
2021-10-24 04:19:25 -05:00
parent d258790199
commit 8d5e0a5b58
6 changed files with 0 additions and 106 deletions

View File

@@ -1,10 +0,0 @@
# A job that deletes a post's files after it's replaced, or a preprocessed
# upload is never completed.
class DeletePostFilesJob < ApplicationJob
queue_as :default
queue_with_priority 20
def perform(id, md5, file_ext)
Post.delete_files(id, md5, file_ext)
end
end

View File

@@ -79,7 +79,6 @@ class UploadService
end
media_asset = MediaAsset.upload!(media_file)
post.queue_delete_files(PostReplacement::DELETION_GRACE_PERIOD)
replacement.replacement_url = replacement_url
replacement.file_ext = media_asset.file_ext

View File

@@ -91,10 +91,6 @@ class Post < ApplicationRecord
end
end
def queue_delete_files(grace_period)
DeletePostFilesJob.set(wait: grace_period).perform_later(id, md5, file_ext)
end
def delete_files
Post.delete_files(id, md5, file_ext, force: true)
end

View File

@@ -1,6 +1,4 @@
class PostReplacement < ApplicationRecord
DELETION_GRACE_PERIOD = 30.days
belongs_to :post
belongs_to :creator, class_name: "User"
before_validation :initialize_fields, on: :create