mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
- Components can't be made into a parent loop, and the parts tree walks stop safely if one exists (logbook entry and squawk resolution pages crashed). - A rejected aircraft photo no longer breaks the edit page; empty photos are refused; images that can't be read aren't resized, and a failed resize sends the original instead of an error. - Unsupported formats (/report.pdf…) answer 406; tampered upload references, out-of-range numbers and constraint violations get a form message instead of a 500; requests with null bytes are refused (400). - Blank values in required columns with defaults take the default; optional links to records that don't exist are validation errors. - Imports (oil report, logbook scans, .sam.zip) accept only uploaded files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
758 B
Ruby
17 lines
758 B
Ruby
# Uploads that claim to be images but can't be read as one (empty, corrupt,
|
|
# or another kind of file with an image name).
|
|
Rails.application.config.to_prepare do
|
|
ActiveStorage::Blob.class_eval do
|
|
# Worth resizing: an image kind that the upload check didn't find
|
|
# unreadable. (Until that check has run, assume it's fine.)
|
|
def resizable_image?
|
|
variable? && !(metadata[:analyzed] && metadata[:width].blank?)
|
|
end
|
|
end
|
|
|
|
# If resizing fails anyway, send the original rather than an error.
|
|
ActiveStorage::Representations::BaseController.rescue_from(Vips::Error, ActiveStorage::InvariableError) do
|
|
redirect_to Rails.application.routes.url_helpers.rails_blob_path(@blob, disposition: params[:disposition], only_path: true)
|
|
end
|
|
end
|