]> cat aescling's git repositories - mastodon.git/commitdiff
Fix crashes in SuspendAccountService/UnsuspendAccountService (#15100)
authorThibG <thib@sitedethib.com>
Sat, 7 Nov 2020 12:16:54 +0000 (13:16 +0100)
committerGitHub <noreply@github.com>
Sat, 7 Nov 2020 12:16:54 +0000 (13:16 +0100)
* Fix crashes in SuspendAccountService/UnsuspendAccountService

* Catch filesystem errors

app/services/suspend_account_service.rb
app/services/unsuspend_account_service.rb

index ea96767fa8d81e3f17a07a251281eec9ef24105c..f08c41e17afff3d988bbbd17274a5178e710d5f5 100644 (file)
@@ -39,11 +39,15 @@ class SuspendAccountService < BaseService
         styles.each do |style|
           case Paperclip::Attachment.default_options[:storage]
           when :s3
-            attachment.s3_object(style).acl.put(:private)
+            attachment.s3_object(style).acl.put(acl: 'private')
           when :fog
             # Not supported
           when :filesystem
-            FileUtils.chmod(0o600 & ~File.umask, attachment.path(style))
+            begin
+              FileUtils.chmod(0o600 & ~File.umask, attachment.path(style)) unless attachment.path(style).nil?
+            rescue Errno::ENOENT
+              Rails.logger.warn "Tried to change permission on non-existent file #{attachment.path(style)}"
+            end
           end
         end
       end
index fe49e3471719c1f0bd326fe98a354a605a177a4e..91dbc9c18417b98c79e93abb333c5b4ea170d81c 100644 (file)
@@ -39,11 +39,15 @@ class UnsuspendAccountService < BaseService
         styles.each do |style|
           case Paperclip::Attachment.default_options[:storage]
           when :s3
-            attachment.s3_object(style).acl.put(Paperclip::Attachment.default_options[:s3_permissions])
+            attachment.s3_object(style).acl.put(acl: Paperclip::Attachment.default_options[:s3_permissions])
           when :fog
             # Not supported
           when :filesystem
-            FileUtils.chmod(0o666 & ~File.umask, attachment.path(style))
+            begin
+              FileUtils.chmod(0o666 & ~File.umask, attachment.path(style)) unless attachment.path(style).nil?
+            rescue Errno::ENOENT
+              Rails.logger.warn "Tried to change permission on non-existent file #{attachment.path(style)}"
+            end
           end
         end
       end