Permalink
Browse files

FIX: error when trying to delete an upload with s3 url

  • Loading branch information...
nlalonde authored and tgxworld committed Oct 4, 2018
1 parent d9dd1c8 commit 652267988416f2d922c595cab50a2b9823bacf51
Showing with 15 additions and 3 deletions.
  1. +5 −3 plugin.rb
  2. +10 −0 spec/models/upload_spec.rb
@@ -92,7 +92,7 @@ def self.plugin_store_key(upload_id)
end
after_destroy do
if ::DiscourseBackupUploadsToS3::Utils.backup_uploads_to_s3?
if ::DiscourseBackupUploadsToS3::Utils.backup_uploads_to_s3? && local_path
Jobs.enqueue(
:remove_upload_from_s3,
path: s3_backup_path,
@@ -107,10 +107,12 @@ def local_path
def compress_backup?
@compress ||= begin
basename = File.basename(local_path)
if FileHelper.respond_to?(:is_supported_image?)
!FileHelper.is_supported_image?(File.basename(local_path))
!FileHelper.is_supported_image?(basename)
else
!FileHelper.is_image?(File.basename(local_path))
!FileHelper.is_image?(basename)
end
end
end
@@ -68,6 +68,16 @@
)
end
it 'should not do anything when a s3 upload is destroyed' do
upload.update!(
url: "//discourse-cloud-file-uploads.s3.dualstack.us-west-2.amazonaws.com/#{upload.url}"
)
expect do
upload.destroy!
end.to change { ::Jobs::RemoveUploadFromS3.jobs.size }.by(0)
end
describe 'when s3 uploads is enabled' do
before do
SiteSetting.s3_access_key_id = 'some_key'

0 comments on commit 6522679

Please sign in to comment.