Bug hint added
Asked on Stackoverflow: https://stackoverflow.com/questions/64615529/how-can-i-avoid-accepting-broken-images-in-activestorage
This commit is contained in:
parent
8b11a77817
commit
2d53397dda
1 changed files with 3 additions and 1 deletions
|
|
@ -62,6 +62,8 @@ class PackagesController < ApplicationController
|
|||
# Log.log "Uploaded img=#{img.path}"
|
||||
new_screenshot = @package.screenshots.new(image: img)
|
||||
|
||||
# BUG: ActiveStorage will accept the broken PNG during upload!
|
||||
|
||||
# Check if the image was valid
|
||||
if new_screenshot.valid?
|
||||
new_screenshot.uploaderhash = session.id.to_s
|
||||
|
|
@ -77,7 +79,7 @@ class PackagesController < ApplicationController
|
|||
new_screenshot.approve! if auto_approve?
|
||||
end
|
||||
|
||||
new_screenshot.save
|
||||
new_screenshot.save!
|
||||
Log.log "Screenshot #{new_screenshot.id} uploaded successfully. ip=#{session[:ip]}. user-token=#{session[:token]}. user-name=#{current_user}"
|
||||
|
||||
@valid_images.push new_screenshot
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue