Merge pull request #3891 from tchak/purge-orphaned-blobs
Purge unattached blobs
This commit is contained in:
commit
b55fae440b
5 changed files with 13 additions and 3 deletions
|
@ -69,6 +69,7 @@ En local, un utilisateur de test est créé automatiquement, avec les identifian
|
||||||
Administrateurs::ActivateBeforeExpirationJob.set(cron: "0 8 * * *").perform_later
|
Administrateurs::ActivateBeforeExpirationJob.set(cron: "0 8 * * *").perform_later
|
||||||
WarnExpiringDossiersJob.set(cron: "0 0 1 * *").perform_later
|
WarnExpiringDossiersJob.set(cron: "0 0 1 * *").perform_later
|
||||||
GestionnaireEmailNotificationJob.set(cron: "0 10 * * 1,2,3,4,5,6").perform_later
|
GestionnaireEmailNotificationJob.set(cron: "0 10 * * 1,2,3,4,5,6").perform_later
|
||||||
|
PurgeUnattachedBlobsJob.set("0 0 * * *").perform_later
|
||||||
|
|
||||||
### Voir les emails envoyés en local
|
### Voir les emails envoyés en local
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ module Gestionnaires
|
||||||
|
|
||||||
def purge_champ_piece_justificative
|
def purge_champ_piece_justificative
|
||||||
@champ = dossier.champs_private.find(params[:champ_id])
|
@champ = dossier.champs_private.find(params[:champ_id])
|
||||||
@champ.piece_justificative_file.purge
|
@champ.piece_justificative_file.purge_later
|
||||||
|
|
||||||
flash.notice = 'La pièce jointe a bien été supprimée.'
|
flash.notice = 'La pièce jointe a bien été supprimée.'
|
||||||
end
|
end
|
||||||
|
|
|
@ -239,7 +239,7 @@ module Users
|
||||||
def purge_champ_piece_justificative
|
def purge_champ_piece_justificative
|
||||||
@champ = dossier.champs.find(params[:champ_id])
|
@champ = dossier.champs.find(params[:champ_id])
|
||||||
|
|
||||||
@champ.piece_justificative_file.purge
|
@champ.piece_justificative_file.purge_later
|
||||||
|
|
||||||
flash.notice = 'La pièce jointe a bien été supprimée.'
|
flash.notice = 'La pièce jointe a bien été supprimée.'
|
||||||
end
|
end
|
||||||
|
|
9
app/jobs/purge_unattached_blobs_job.rb
Normal file
9
app/jobs/purge_unattached_blobs_job.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class PurgeUnattachedBlobsJob < ApplicationJob
|
||||||
|
queue_as :cron
|
||||||
|
|
||||||
|
def perform(*args)
|
||||||
|
ActiveStorage::Blob.unattached
|
||||||
|
.where('active_storage_blobs.created_at < ?', 24.hours.ago)
|
||||||
|
.find_each(&:purge_later)
|
||||||
|
end
|
||||||
|
end
|
|
@ -40,7 +40,7 @@ class Champs::PieceJustificativeChamp < Champ
|
||||||
end
|
end
|
||||||
|
|
||||||
if errors.present?
|
if errors.present?
|
||||||
piece_justificative_file.purge
|
piece_justificative_file.purge_later
|
||||||
end
|
end
|
||||||
|
|
||||||
errors
|
errors
|
||||||
|
|
Loading…
Add table
Reference in a new issue