Skip to content
Snippets Groups Projects
Unverified Commit c1de6730 authored by Claire's avatar Claire Committed by GitHub
Browse files

Fix suspension worker crashing on S3-compatible setups without ACL support (#22487)

parent 2bad619d
No related branches found
No related tags found
No related merge requests found
...@@ -76,10 +76,15 @@ class SuspendAccountService < BaseService ...@@ -76,10 +76,15 @@ class SuspendAccountService < BaseService
styles.each do |style| styles.each do |style|
case Paperclip::Attachment.default_options[:storage] case Paperclip::Attachment.default_options[:storage]
when :s3 when :s3
# Prevent useless S3 calls if ACLs are disabled
next if ENV['S3_PERMISSION'] == ''
begin begin
attachment.s3_object(style).acl.put(acl: 'private') attachment.s3_object(style).acl.put(acl: 'private')
rescue Aws::S3::Errors::NoSuchKey rescue Aws::S3::Errors::NoSuchKey
Rails.logger.warn "Tried to change acl on non-existent key #{attachment.s3_object(style).key}" Rails.logger.warn "Tried to change acl on non-existent key #{attachment.s3_object(style).key}"
rescue Aws::S3::Errors::NotImplemented => e
Rails.logger.error "Error trying to change ACL on #{attachment.s3_object(style).key}: #{e.message}"
end end
when :fog when :fog
# Not supported # Not supported
......
...@@ -73,10 +73,15 @@ class UnsuspendAccountService < BaseService ...@@ -73,10 +73,15 @@ class UnsuspendAccountService < BaseService
styles.each do |style| styles.each do |style|
case Paperclip::Attachment.default_options[:storage] case Paperclip::Attachment.default_options[:storage]
when :s3 when :s3
# Prevent useless S3 calls if ACLs are disabled
next if ENV['S3_PERMISSION'] == ''
begin begin
attachment.s3_object(style).acl.put(acl: Paperclip::Attachment.default_options[:s3_permissions]) attachment.s3_object(style).acl.put(acl: Paperclip::Attachment.default_options[:s3_permissions])
rescue Aws::S3::Errors::NoSuchKey rescue Aws::S3::Errors::NoSuchKey
Rails.logger.warn "Tried to change acl on non-existent key #{attachment.s3_object(style).key}" Rails.logger.warn "Tried to change acl on non-existent key #{attachment.s3_object(style).key}"
rescue Aws::S3::Errors::NotImplemented => e
Rails.logger.error "Error trying to change ACL on #{attachment.s3_object(style).key}: #{e.message}"
end end
when :fog when :fog
# Not supported # Not supported
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment