StorageManager: remove Post-specific code.

Refactor StorageManager to remove all image URL generation code. Instead
the image URL generation code lives in MediaAsset.

Now StorageManager is only concerned with how to read and write files to
remote storage backends like S3 or SFTP, not with how image URLs should
be generated. This way the file storage code isn't tightly coupled to
posts, so it can be used to store any kind of file, not just images
belonging to posts.
This commit is contained in:
evazion
2021-10-26 19:11:37 -05:00
parent afe5095ee6
commit 082544ab03
7 changed files with 33 additions and 172 deletions

View File

@@ -70,8 +70,7 @@ namespace :danbooru do
MediaMetadata.joins(:media_asset).where(metadata: {}).find_each do |metadata|
asset = metadata.media_asset
file = sm.open(sm.file_path(asset.md5, asset.file_ext, :original))
media_file = MediaFile.open(file)
media_file = asset.variant(:original).open_file
metadata.update!(metadata: media_file.metadata)
puts "metadata[id=#{metadata.id}, md5=#{asset.md5}]: #{media_file.metadata.count}"