Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove stale `s3:correct_acl` and `s3:correct_cachecontrol` tasks (#33005)

Alan Guo Xiang Tan0187853aad93
diff --git a/lib/tasks/s3.rake b/lib/tasks/s3.rake
index 6047e968984..9550a714275 100644
--- a/lib/tasks/s3.rake
+++ b/lib/tasks/s3.rake
@@ -89,82 +89,6 @@ def ensure_s3_configured!
end
end
-task "s3:correct_acl" => :environment do
- ensure_s3_configured!
-
- if !SiteSetting.s3_use_acls
- $stderr.puts "Not correcting ACLs as the site is configured to not use ACLs"
- return
- end
-
- puts "ensuring public-read is set on every upload and optimized image"
-
- i = 0
-
- base_url = Discourse.store.absolute_base_url
-
- objects = Upload.pluck(:id, :url).map { |array| array << :upload }
- objects.concat(OptimizedImage.pluck(:id, :url).map { |array| array << :optimized_image })
-
- puts "#{objects.length} objects found"
-
- objects.each do |id, url, type|
- i += 1
- if !url.start_with?(base_url)
- puts "Skipping #{type} #{id} since it is not stored on s3, url is #{url}"
- else
- begin
- key = url[(base_url.length + 1)..-1]
- object = Discourse.store.s3_helper.object(key)
- object.acl.put(acl: "public-read")
- rescue => e
- puts "Skipping #{type} #{id} url is #{url} #{e}"
- end
- end
- puts "#{i} done" if i % 100 == 0
- end
-end
-
-task "s3:correct_cachecontrol" => :environment do
- ensure_s3_configured!
-
- puts "ensuring cache-control is set on every upload and optimized image"
-
- i = 0
-
- base_url = Discourse.store.absolute_base_url
-
- cache_control = "max-age=31556952, public, immutable"
-
- objects = Upload.pluck(:id, :url).map { |array| array << :upload }
- objects.concat(OptimizedImage.pluck(:id, :url).map { |array| array << :optimized_image })
-
- puts "#{objects.length} objects found"
-
- objects.each do |id, url, type|
- i += 1
- if !url.start_with?(base_url)
- puts "Skipping #{type} #{id} since it is not stored on s3, url is #{url}"
- else
- begin
- key = url[(base_url.length + 1)..-1]
- object = Discourse.store.s3_helper.object(key)
- object.copy_from(
- copy_source: "#{object.bucket_name}/#{object.key}",
- acl: SiteSetting.s3_use_acls ? "public-read" : nil,
- cache_control: cache_control,
- content_type: object.content_type,
- content_disposition: object.content_disposition,
- metadata_directive: "REPLACE",
- )
- rescue => e
- puts "Skipping #{type} #{id} url is #{url} #{e}"
- end
- end
- puts "#{i} done" if i % 100 == 0
- end
-end
-
task "s3:ensure_cors_rules" => :environment do
ensure_s3_configured!