Skip to content

A platform for community discussion. Free, open, simple.

DEV: Limit upload JPEG conversion writes to the output file (#43805)

Alan Guo Xiang Tan1982b6e01e65
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb
index 6d06124170c..24a1c1a6fb0 100644
--- a/lib/upload_creator.rb
+++ b/lib/upload_creator.rb
@@ -353,7 +353,7 @@ class UploadCreator
OptimizedImage.ensure_safe_paths!(from, to)
read = [@file.path]
- write = [File.dirname(jpeg_tempfile.path)]
+ write = [jpeg_tempfile.path]
if GlobalSetting.enable_vips_image_processing
DiscourseVips.heif_to_jpeg(
@@ -679,14 +679,14 @@ class UploadCreator
quality:,
timeout: MAX_CONVERT_FORMAT_SECONDS,
read: [from],
- write: [File.dirname(to)],
+ write: [jpeg_tempfile.path],
)
else
from = OptimizedImage.prepend_decoder!(from, nil, filename: "image.#{@image_info.type}")
to = OptimizedImage.prepend_decoder!(to)
opts = { quality: }
read = [@file.path]
- write = [File.dirname(jpeg_tempfile.path)]
+ write = [jpeg_tempfile.path]
begin
execute_convert(from, to, opts, read:, write:)