DEV: Update call sites using BaseStore#download but expecting exceptions (#21551)
In #21498, we split `BaseStore#download` into a "safe" version which returns nil on errors, and an "unsafe" version which raises an exception, which was the old behaviour of `#download`. This change updates call sites that used the old `#download`, which raised exceptions, to use the new `#download!` to preserve behaviour (and silence deprecation warnings.) It also silences the deprecation warning in tests.
This commit is contained in:
parent
8d58b1c6b8
commit
a2bc24456f
|
@ -146,7 +146,7 @@ class OptimizedImage < ActiveRecord::Base
|
||||||
if local?
|
if local?
|
||||||
Discourse.store.path_for(self)
|
Discourse.store.path_for(self)
|
||||||
else
|
else
|
||||||
Discourse.store.download(self).path
|
Discourse.store.download!(self).path
|
||||||
end
|
end
|
||||||
File.size(path)
|
File.size(path)
|
||||||
end
|
end
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Upload < ActiveRecord::Base
|
||||||
external_copy = nil
|
external_copy = nil
|
||||||
|
|
||||||
if original_path.blank?
|
if original_path.blank?
|
||||||
external_copy = Discourse.store.download(self)
|
external_copy = Discourse.store.download!(self)
|
||||||
original_path = external_copy.path
|
original_path = external_copy.path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -268,14 +268,14 @@ class Upload < ActiveRecord::Base
|
||||||
def fix_dimensions!
|
def fix_dimensions!
|
||||||
return if !FileHelper.is_supported_image?("image.#{extension}")
|
return if !FileHelper.is_supported_image?("image.#{extension}")
|
||||||
|
|
||||||
path =
|
|
||||||
if local?
|
|
||||||
Discourse.store.path_for(self)
|
|
||||||
else
|
|
||||||
Discourse.store.download(self).path
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
path =
|
||||||
|
if local?
|
||||||
|
Discourse.store.path_for(self)
|
||||||
|
else
|
||||||
|
Discourse.store.download!(self).path
|
||||||
|
end
|
||||||
|
|
||||||
if extension == "svg"
|
if extension == "svg"
|
||||||
w, h =
|
w, h =
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -363,7 +363,7 @@ module Email
|
||||||
if attached_upload.local?
|
if attached_upload.local?
|
||||||
Discourse.store.path_for(attached_upload)
|
Discourse.store.path_for(attached_upload)
|
||||||
else
|
else
|
||||||
Discourse.store.download(attached_upload).path
|
Discourse.store.download!(attached_upload).path
|
||||||
end
|
end
|
||||||
|
|
||||||
@message_attachments_index[original_upload.sha1] = @message.attachments.size
|
@message_attachments_index[original_upload.sha1] = @message.attachments.size
|
||||||
|
|
|
@ -105,7 +105,7 @@ module FileStore
|
||||||
end
|
end
|
||||||
|
|
||||||
def download(object, max_file_size_kb: nil, print_deprecation: true)
|
def 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_deprecation
|
||||||
In a future version `FileStore#download` will no longer raise an error when the
|
In a future version `FileStore#download` will no longer raise an error when the
|
||||||
download fails, and will instead return `nil`. If you need a method that raises
|
download fails, and will instead return `nil`. If you need a method that raises
|
||||||
an error, use `FileStore#download!`, which raises a `FileStore::DownloadError`.
|
an error, use `FileStore#download!`, which raises a `FileStore::DownloadError`.
|
||||||
|
|
Loading…
Reference in New Issue