From 8acc75435b4dcf959b6d5bb15c429abeef098437 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 21 Sep 2023 14:00:51 +0200 Subject: [PATCH] Change S3 checksum mode to be disabled by default (#27007) --- config/initializers/paperclip.rb | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 02943ce09..03e5fdbb8 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -91,28 +91,26 @@ if ENV['S3_ENABLED'] == 'true' # Some S3-compatible providers might not actually be compatible with some APIs # used by kt-paperclip, see https://github.com/mastodon/mastodon/issues/16822 # and https://github.com/mastodon/mastodon/issues/26394 - if ENV['S3_FORCE_SINGLE_REQUEST'] == 'true' || ENV['S3_DISABLE_CHECKSUM_MODE'] == 'true' - module Paperclip - module Storage - module S3Extensions - def copy_to_local_file(style, local_dest_path) - log("copying #{path(style)} to local file #{local_dest_path}") + module Paperclip + module Storage + module S3Extensions + def copy_to_local_file(style, local_dest_path) + log("copying #{path(style)} to local file #{local_dest_path}") - options = {} - options[:mode] = 'single_request' if ENV['S3_FORCE_SINGLE_REQUEST'] == 'true' - options[:checksum_mode] = 'DISABLED' if ENV['S3_DISABLE_CHECKSUM_MODE'] == 'true' + options = {} + options[:mode] = 'single_request' if ENV['S3_FORCE_SINGLE_REQUEST'] == 'true' + options[:checksum_mode] = 'DISABLED' unless ENV['S3_ENABLE_CHECKSUM_MODE'] == 'true' - s3_object(style).download_file(local_dest_path, options) - rescue Aws::Errors::ServiceError => e - warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}") - false - end + s3_object(style).download_file(local_dest_path, options) + rescue Aws::Errors::ServiceError => e + warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}") + false end end end - - Paperclip::Storage::S3.prepend(Paperclip::Storage::S3Extensions) end + + Paperclip::Storage::S3.prepend(Paperclip::Storage::S3Extensions) elsif ENV['SWIFT_ENABLED'] == 'true' require 'fog/openstack'