New features
Shrine::Attacher.promote
andShrine::Attacher.delete
from the backgrounding plugin now return the record (unless the record wasn't found or the action aborted).
class PromoteJob
include Sidekiq::Worker
def perform(data)
record = Shrine::Attacher.promote(data)
record.update(published: true) if record.is_a?(Post)
end
end
Other improvements
Custom metadata (which can be set by overriding
Shrine#extract_metadata
) is now properly inherited from cached files, andShrine#extact_metadata
is now only called once.If the record was deleted before the background job for promoting started, instead of erroring, the job now ignores that error and immediately finishes.
Fixed a very unlikely scenario where a background job could replaced an updated attachment on subsequent attachment updates, by wrapping the check if the attachment changed and updating the attachment in a database transaction.
Prevented starting the background job if the attachment has already changed, which fixes a relatively harmless attack where the end user could create a lot of retrying jobs by updating the attachment with a corrupted file.
All IOs are now closed even if their upload errors.