posts: mark media asset as expunged when post is expunged.

Fix it so that when a post is expunged, the media asset is also marked
as expunged. This way the files will be deleted, but the media asset
will still remain as a record of what was expunged. The media asset will
have the md5, width, height, file ext, and file size of the deleted file.
This commit is contained in:
evazion
2021-10-26 02:47:01 -05:00
parent 84212acfae
commit afe5095ee6
4 changed files with 16 additions and 27 deletions

View File

@@ -179,6 +179,14 @@ class MediaAsset < ApplicationRecord
self.pixiv_ugoira_frame_data = PixivUgoiraFrameData.new(data: media_file.frame_data, content_type: "image/jpeg") if is_ugoira?
end
def expunge!
delete_files!
update!(status: :expunged)
rescue
update!(status: :failed)
raise
end
def delete_files!
variants.each(&:delete_file!)
end