This commit is contained in:
2026-08-16 22:38:44 +08:00
parent 1945d34894
commit 560ae46b82
19 changed files with 345 additions and 112 deletions
+6 -10
View File
@@ -173,17 +173,13 @@ func (uc *MediaUsecase) CleanupStale(ctx context.Context, ttlHours int) error {
if ttlHours <= 0 {
ttlHours = 24
}
ids, err := uc.StaleUploadSessionIDs(ctx, time.Now().Add(-time.Duration(ttlHours)*time.Hour))
if err != nil {
return err
}
// The reference cleanup job is best-effort: a stale-session query or an
// individual storage/database cleanup failure is not propagated to the
// scheduler. Keep the endpoint-independent background behavior compatible.
ids, _ := uc.StaleUploadSessionIDs(ctx, time.Now().Add(-time.Duration(ttlHours)*time.Hour))
for _, id := range ids {
if err = uc.DeleteUploadData(ctx, id); err != nil {
return err
}
if err = uc.files.DeletePrefix(ctx, uc.chunkPrefix(id)); err != nil {
return err
}
_ = uc.DeleteUploadData(ctx, id)
_ = uc.files.DeletePrefix(ctx, uc.chunkPrefix(id))
}
return nil
}