From 49e835395966fbddb9ad2988961d8375e501151f Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Wed, 11 Dec 2024 11:19:38 +0800 Subject: [PATCH] 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. --- lib/tasks/s3.rake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tasks/s3.rake b/lib/tasks/s3.rake index 39ec32b3364..d01bd09ee71 100644 --- a/lib/tasks/s3.rake +++ b/lib/tasks/s3.rake @@ -61,7 +61,7 @@ def assets Rails.application.config.assets.manifest, ) - results = [] + results = Set.new manifest.assets.each do |_, path| 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 content_type = MiniMime.lookup_by_filename(fullpath)&.content_type content_type ||= "application/json" if fullpath.end_with?(".map") + if content_type asset_path = "assets/#{path}" results << [fullpath, asset_path, content_type] @@ -87,7 +88,7 @@ def assets end end - results + results.to_a end def asset_paths