优化
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user