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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user