logic made nicer

This commit is contained in:
Christoph Haas 2025-06-26 23:33:32 +02:00
parent 9de9f93489
commit 19f85a27d6

View file

@ -296,15 +296,21 @@ class PackagesController < ApplicationController
end end
# Return a 404 if the package has no screenshots or the image was not found # Return a 404 if the package has no screenshots or the image was not found
unless @image if @image
send_file(File.join(@image.simage.storage.directory, @image.simage(size).id),
disposition: 'inline')
else
Rails.logger.debug 'no such image -> 404' Rails.logger.debug 'no such image -> 404'
screenshot404 if %i[large small].include?(size) case size
thumbnail404 if size == :thumb when :large
return screenshot404
when :small
screenshot404
when :thumb
Rails.logger.debug 'thumb404'
thumbnail404
end
end end
send_file(File.join(@image.simage.storage.directory, @image.simage(size).id),
disposition: 'inline')
end end
# Receives a form with a simple text field 'description' so that users can update # Receives a form with a simple text field 'description' so that users can update