Skip to content

Commit

Permalink
🐛 Fix schedule deletion will delete referenced file
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSheep2Code committed Aug 18, 2024
1 parent a65b761 commit 1cce7c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/internal/services/recycler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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).
Expand Down

0 comments on commit 1cce7c9

Please sign in to comment.