🐛 Fix the cloud file deletion

This commit is contained in:
LittleSheep 2025-05-31 02:48:36 +08:00
parent 6670c69fda
commit ed2e9571ab

View File

@ -541,7 +541,7 @@ public class CloudFileUnusedRecyclingJob(AppDatabase db, FileService fs, ILogger
var files = await db.Files var files = await db.Files
.Where(f => .Where(f =>
(f.ExpiredAt == null && f.UsedCount == 0 && f.CreatedAt < cutoff) || (f.ExpiredAt == null && f.UsedCount == 0 && f.CreatedAt < cutoff) ||
(f.ExpiredAt != null && f.ExpiredAt >= now) (f.ExpiredAt != null && now >= f.ExpiredAt)
) )
.ToListAsync(); .ToListAsync();
@ -573,10 +573,8 @@ public class CloudFileUnusedRecyclingJob(AppDatabase db, FileService fs, ILogger
.ToDictionary(grouping => grouping.Key!, grouping => grouping.ToList()); .ToDictionary(grouping => grouping.Key!, grouping => grouping.ToList());
// Delete files by remote storage // Delete files by remote storage
foreach (var group in filesToDelete) foreach (var group in filesToDelete.Where(group => !string.IsNullOrEmpty(group.Key)))
{ {
if (string.IsNullOrEmpty(group.Key)) continue;
try try
{ {
var dest = fs.GetRemoteStorageConfig(group.Key); var dest = fs.GetRemoteStorageConfig(group.Key);