1
0
Fork 0
forked from OpenNeo/impress

Fix crash when dealing with 404'd manifests

First off, I think our code has converged on a convention of gracefully
returning `nil` for manifest-less situations, so we can do that instead
of raise! And then that lets us just simplify this check to whether
`manifest` is present, instead of `manifest_url`, so we stop crashing
in cases where we get to this point in the code and there's a manifest
URL but not a manifest.
This commit is contained in:
Emi Matchu 2024-02-25 16:05:43 -08:00
parent 2cac048158
commit fb2bdd6ea5

View file

@ -59,7 +59,7 @@ class SwfAsset < ApplicationRecord
end end
def load_manifest(return_content: true, save_changes: true) def load_manifest(return_content: true, save_changes: true)
raise "manifest_url is blank" if manifest_url.blank? return nil if manifest_url.blank?
# If we recently tried loading the manifest and got a 4xx HTTP status code # If we recently tried loading the manifest and got a 4xx HTTP status code
# (e.g. a 404, there's a surprising amount of these!), don't try again. But # (e.g. a 404, there's a surprising amount of these!), don't try again. But
@ -109,7 +109,7 @@ class SwfAsset < ApplicationRecord
MANIFEST_BASE_URL = Addressable::URI.parse("https://images.neopets.com") MANIFEST_BASE_URL = Addressable::URI.parse("https://images.neopets.com")
def manifest_asset_urls def manifest_asset_urls
return {} if manifest_url.nil? return {} unless manifest.present?
begin begin
# Organize the asset URLs by file extension, convert them from paths to # Organize the asset URLs by file extension, convert them from paths to