A platform for community discussion. Free, open, simple.
DEV: Update call sites using BaseStore#download but expecting exceptions (#21551)
Ted Johanssona2bc24456f53
diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rbindex ff3b5a6c089..25dd5b860a0 100644--- a/app/models/optimized_image.rb+++ b/app/models/optimized_image.rb@@ -146,7 +146,7 @@ class OptimizedImage < ActiveRecord::Baseif local?Discourse.store.path_for(self)else- Discourse.store.download(self).path+ Discourse.store.download!(self).pathendFile.size(path)enddiff --git a/app/models/upload.rb b/app/models/upload.rbindex a3b62cedb3e..cea39988f8e 100644--- a/app/models/upload.rb+++ b/app/models/upload.rb@@ -144,7 +144,7 @@ class Upload < ActiveRecord::Baseexternal_copy = nilif original_path.blank?- external_copy = Discourse.store.download(self)+ external_copy = Discourse.store.download!(self)original_path = external_copy.pathend@@ -268,14 +268,14 @@ class Upload < ActiveRecord::Basedef fix_dimensions!return if !FileHelper.is_supported_image?("image.#{extension}")- path =- if local?- Discourse.store.path_for(self)- else- Discourse.store.download(self).path- end-begin+ path =+ if local?+ Discourse.store.path_for(self)+ else+ Discourse.store.download!(self).path+ end+if extension == "svg"w, h =begindiff --git a/lib/email/sender.rb b/lib/email/sender.rbindex 0f62d07bc95..fceb484322b 100644--- a/lib/email/sender.rb+++ b/lib/email/sender.rb@@ -363,7 +363,7 @@ module Emailif attached_upload.local?Discourse.store.path_for(attached_upload)else- Discourse.store.download(attached_upload).path+ Discourse.store.download!(attached_upload).pathend@message_attachments_index[original_upload.sha1] = @message.attachments.sizediff --git a/lib/file_store/base_store.rb b/lib/file_store/base_store.rbindex e896bf5d8ae..ff98b06231a 100644--- a/lib/file_store/base_store.rb+++ b/lib/file_store/base_store.rb@@ -105,7 +105,7 @@ module FileStoreenddef download(object, max_file_size_kb: nil, print_deprecation: true)- Discourse.deprecate(<<~MESSAGE, output_in_test: true) if print_deprecation+ Discourse.deprecate(<<~MESSAGE) if print_deprecationIn a future version `FileStore#download` will no longer raise an error when thedownload fails, and will instead return `nil`. If you need a method that raisesan error, use `FileStore#download!`, which raises a `FileStore::DownloadError`.