Merge pull request #10387 from demarches-simplifiees/recompute_blob_checksum
Tech: ajoute une maintenance task pour recalculer les checksums de pj erronées
This commit is contained in:
commit
1b2cd09737
1 changed files with 23 additions and 0 deletions
23
app/tasks/maintenance/recompute_blob_checksum_task.rb
Normal file
23
app/tasks/maintenance/recompute_blob_checksum_task.rb
Normal 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
|
Loading…
Reference in a new issue