DEV: Avoid initializing max_image_size_kb in initializer (#28209)

Since this might initialize to the default db's values
rather than that of the site.
This commit is contained in:
Natalie Tay 2024-08-02 23:15:14 +08:00 committed by GitHub
parent 6ec8728ebf
commit 624dc87321
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 3 deletions

View File

@ -5,7 +5,6 @@ module Jobs
sidekiq_options queue: "low"
def initialize
@max_size = SiteSetting.max_image_size_kb.kilobytes
end
def execute(args)
@ -101,7 +100,7 @@ module Jobs
downloaded =
FileHelper.download(
src,
max_file_size: @max_size,
max_file_size: SiteSetting.max_image_size_kb.kilobytes,
retain_on_max_file_size_exceeded: true,
tmp_file_name: "discourse-hotlinked",
follow_redirect: true,
@ -137,7 +136,9 @@ module Jobs
hotlinked = download(src)
raise ImageBrokenError if !hotlinked
raise ImageTooLargeError if File.size(hotlinked.path) > @max_size
if File.size(hotlinked.path) > SiteSetting.max_image_size_kb.kilobytes
raise ImageTooLargeError
end
filename = File.basename(URI.parse(src).path)
filename << File.extname(hotlinked.path) unless filename["."]