FIX: s3:upload_assets was uploaded some source maps twice (#30216)

This is because Sprocket's manifest already contains the source maps.
The easy and safe fix here is to just use a `Set` to prevent
duplications.
This commit is contained in:
Alan Guo Xiang Tan 2024-12-11 11:19:38 +08:00 committed by GitHub
parent b9f8a77d9b
commit 49e8353959
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -61,7 +61,7 @@ def assets
Rails.application.config.assets.manifest, Rails.application.config.assets.manifest,
) )
results = [] results = Set.new
manifest.assets.each do |_, path| manifest.assets.each do |_, path|
fullpath = (Rails.root + "public/assets/#{path}").to_s fullpath = (Rails.root + "public/assets/#{path}").to_s
@ -69,6 +69,7 @@ def assets
# Ignore files we can't find the mime type of, like yarn.lock # Ignore files we can't find the mime type of, like yarn.lock
content_type = MiniMime.lookup_by_filename(fullpath)&.content_type content_type = MiniMime.lookup_by_filename(fullpath)&.content_type
content_type ||= "application/json" if fullpath.end_with?(".map") content_type ||= "application/json" if fullpath.end_with?(".map")
if content_type if content_type
asset_path = "assets/#{path}" asset_path = "assets/#{path}"
results << [fullpath, asset_path, content_type] results << [fullpath, asset_path, content_type]
@ -87,7 +88,7 @@ def assets
end end
end end
results results.to_a
end end
def asset_paths def asset_paths