mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 14:04:36 +08:00
FIX: Use File.size instead of IO.size
This commit is contained in:
@ -61,15 +61,15 @@ class UploadsController < ApplicationController
|
||||
end
|
||||
|
||||
# allow users to upload large images that will be automatically reduced to allowed size
|
||||
if tempfile && tempfile.size > 0 && SiteSetting.max_image_size_kb > 0 && FileHelper.is_image?(filename)
|
||||
if tempfile && File.size(tempfile.path) > 0 && SiteSetting.max_image_size_kb > 0 && FileHelper.is_image?(filename)
|
||||
attempt = 5
|
||||
while attempt > 0 && tempfile.size > SiteSetting.max_image_size_kb.kilobytes
|
||||
while attempt > 0 && File.size(tempfile.path) > SiteSetting.max_image_size_kb.kilobytes
|
||||
OptimizedImage.downsize(tempfile.path, tempfile.path, "80%", allow_animation: SiteSetting.allow_animated_thumbnails)
|
||||
attempt -= 1
|
||||
end
|
||||
end
|
||||
|
||||
upload = Upload.create_for(current_user.id, tempfile, filename, tempfile.size, content_type: content_type, image_type: type)
|
||||
upload = Upload.create_for(current_user.id, tempfile, filename, File.size(tempfile.path), content_type: content_type, image_type: type)
|
||||
|
||||
if upload.errors.empty? && current_user.admin?
|
||||
retain_hours = params[:retain_hours].to_i
|
||||
|
Reference in New Issue
Block a user