From 85e8d1f2859742c3f455ed6b70ba06b4ee86d249 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 30 Aug 2024 05:46:09 -0400 Subject: [PATCH] Use rails configuration storage for paperclip path (#31651) --- config/initializers/paperclip.rb | 3 ++- lib/mastodon/cli/media.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 6b14985ae30..ed16d50a76d 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -160,9 +160,10 @@ elsif ENV['AZURE_ENABLED'] == 'true' ) end else + Rails.configuration.x.file_storage_root_path = ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')) Paperclip::Attachment.default_options.merge!( storage: :filesystem, - path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':prefix_path:class', ':attachment', ':id_partition', ':style', ':filename'), + path: File.join(Rails.configuration.x.file_storage_root_path, ':prefix_path:class', ':attachment', ':id_partition', ':style', ':filename'), url: ENV.fetch('PAPERCLIP_ROOT_URL', '/system') + "/#{PATH}" ) end diff --git a/lib/mastodon/cli/media.rb b/lib/mastodon/cli/media.rb index 123973d1954..70c11ee1a15 100644 --- a/lib/mastodon/cli/media.rb +++ b/lib/mastodon/cli/media.rb @@ -157,7 +157,7 @@ module Mastodon::CLI when :filesystem require 'find' - root_path = ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')).gsub(':rails_root', Rails.root.to_s) + root_path = Rails.configuration.x.file_storage_root_path.gsub(':rails_root', Rails.root.to_s) Find.find(File.join(*[root_path, prefix].compact)) do |path| next if File.directory?(path)