discourse/app/jobs/regular/sync_acls_for_uploads.rb
Alan Guo Xiang Tan 061d6fd7a7
DEV: Remove log messages that are redundant (#30466)
I think the log messages were used for initial production trials but the
log messages are actually not very useful in the grand scheme of things.
If the timing of the job is important information, one can get it by
enabling Sidekiq logging and obtain the information from there. There is
no need for us to flood the logs with these messages.

Also the messages will contain at most 100 ids so it is just alot of
noise in general.
2024-12-26 09:54:09 +08:00

39 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module Jobs
# Sometimes we need to update a _lot_ of ACLs on S3 (such as when secure uploads
# is enabled), and since it takes ~1s per upload to update the ACL, this is
# best spread out over many jobs instead of having to do the whole thing serially.
class SyncAclsForUploads < ::Jobs::Base
sidekiq_options queue: "low"
def execute(args)
return if !Discourse.store.external?
return if !args.key?(:upload_ids)
time =
Benchmark.measure do
Upload
.includes(:optimized_images)
.where(id: args[:upload_ids])
.find_in_batches do |uploads|
uploads.each do |upload|
begin
Discourse.store.update_upload_ACL(upload, optimized_images_preloaded: true)
rescue => err
Discourse.warn_exception(
err,
message: "Failed to update upload ACL",
env: {
upload_id: upload.id,
filename: upload.original_filename,
},
)
end
end
end
end
end
end
end