🐛 Fix schedule deletion will delete referenced file

This commit is contained in:
2024-08-18 16:16:37 +08:00
parent a65b761d5e
commit 1cce7c9b81
2 changed files with 8 additions and 5 deletions

View File

@ -51,7 +51,7 @@ func RunMarkDeletionTask() {
for _, pool := range pendingPools {
lifecycle := fmt.Sprintf("%d seconds", *pool.Config.Data().ExistLifecycle)
tx := database.C.
Where("pool_id = ? AND created_at < NOW() - INTERVAL ?", pool.ID, lifecycle).
Where("pool_id = ? AND AND created_at < NOW() - INTERVAL ?", pool.ID, lifecycle).
Updates(&models.Attachment{CleanedAt: lo.ToPtr(time.Now())})
log.Info().
Str("pool", pool.Alias).
@ -68,6 +68,9 @@ func RunScheduleDeletionTask() {
}
for idx, attachment := range attachments {
if attachment.RefID != nil {
continue
}
if err := DeleteFile(attachment); err != nil {
log.Error().
Uint("id", attachment.ID).