chore(blob): add maintenance task to recompute blob checksum

This commit is contained in:
simon lehericey 2024-04-29 10:06:33 +02:00
parent 396384cfa9
commit d2987582f1
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5

View file

@ -0,0 +1,23 @@
# frozen_string_literal: true
module Maintenance
class RecomputeBlobChecksumTask < MaintenanceTasks::Task
attribute :blob_ids, :string
validates :blob_ids, presence: true
def collection
ids = blob_ids.split(',').map(&:strip).map(&:to_i)
ActiveStorage::Blob.where(id: ids)
end
def process(blob)
blob.upload(StringIO.new(blob.download), identify: false)
blob.save!
end
def count
# Optionally, define the number of rows that will be iterated over
# This is used to track the task's progress
end
end
end