Skip to content

Commit

Permalink
DEV: Add script for preprocessing uploads as part of a migration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gschlager committed Dec 11, 2023
1 parent 1cb6002 commit d725b3c
Show file tree
Hide file tree
Showing 3 changed files with 712 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/optimized_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def self.prepend_decoder!(path, ext_path = nil, opts = nil)
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

Expand Down
Loading

0 comments on commit d725b3c

Please sign in to comment.