Skip to content

Commit

Permalink
Fix crashes in SuspendAccountService/UnsuspendAccountService (mastodo…
Browse files Browse the repository at this point in the history
…n#15100)

* Fix crashes in SuspendAccountService/UnsuspendAccountService

* Catch filesystem errors
  • Loading branch information
ClearlyClaire authored and umonaca committed Nov 8, 2020
1 parent 5e25f3c commit a85cccb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/services/suspend_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ def privatize_media_attachments!
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
Expand Down
8 changes: 6 additions & 2 deletions app/services/unsuspend_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ def publish_media_attachments!
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
Expand Down

0 comments on commit a85cccb

Please sign in to comment.