DEV: Add script for preprocessing uploads as part of a migration

This script preprocesses all uploads within a intermediate DB (output of converters) and uploads those files to S3. It does the same for optimized images. This speeds up migrations when you have to run them multiple times, because you only have to preprocess and upload the files once.

This script is very hacky and mostly undocumented for now. That will change in the future.
This commit is contained in:
Gerhard Schlager
2023-12-10 22:38:15 +01:00
committed by Gerhard Schlager
parent 1cb600270e
commit d725b3ca9e
3 changed files with 712 additions and 1 deletions

View File

@@ -192,7 +192,9 @@ class OptimizedImage < ActiveRecord::Base
extension = File.extname(opts[:filename] || ext_path || path)[1..-1]
end
raise Discourse::InvalidAccess if !extension || !extension.match?(IM_DECODERS)
if !extension || !extension.match?(IM_DECODERS)
raise Discourse::InvalidAccess.new("Unsupported extension: #{extension}")
end
"#{extension}:#{path}"
end