This commit is contained in:
2026-06-01 00:24:41 +02:00
parent 539899741d
commit 842b1ffd08
12 changed files with 22 additions and 44 deletions
@@ -16,8 +16,8 @@ namespace Musify.Infrastructure.Jobs
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
logger.LogInformation("TemporalUploadsCleanUpJob started (interval: {Interval}s, prefix: {Prefix})",
uploadIntentConfiguration.TempCleanupJobIntervalSeconds,
uploadIntentConfiguration.TempRootPrefix);
uploadIntentConfiguration.TemporalCleanUpJobIntervalSeconds,
uploadIntentConfiguration.TemporalRootPrefix);
while (!stoppingToken.IsCancellationRequested)
{
@@ -30,7 +30,7 @@ namespace Musify.Infrastructure.Jobs
logger.LogError(exception, "Error in TemporalUploadsCleanUpJob");
}
await Task.Delay(TimeSpan.FromSeconds(uploadIntentConfiguration.TempCleanupJobIntervalSeconds), stoppingToken);
await Task.Delay(TimeSpan.FromSeconds(uploadIntentConfiguration.TemporalCleanUpJobIntervalSeconds), stoppingToken);
}
}
@@ -39,13 +39,13 @@ namespace Musify.Infrastructure.Jobs
await using var scope = scopeFactory.CreateAsyncScope();
var storageService = scope.ServiceProvider.GetRequiredService<IStorageService>();
var cutOff = DateTime.UtcNow.AddDays(-uploadIntentConfiguration.TempUploadsRetentionDays);
var cutOff = DateTime.UtcNow.AddDays(-uploadIntentConfiguration.TemporalUploadsRetentionDays);
var deleted = 0;
var errors = 0;
await foreach (var (key, lastModified) in storageService.ListObjectsAsync(
storageConfiguration.Bucket,
uploadIntentConfiguration.TempRootPrefix,
uploadIntentConfiguration.TemporalRootPrefix,
cancellationToken))
{
if (lastModified >= cutOff)
@@ -40,7 +40,6 @@ namespace Musify.Infrastructure.Jobs
var now = DateTime.UtcNow;
// Mark expired intents
var expiredIntents = await database.UploadIntents
.Where(i => i.Status == UploadIntentStatus.Issued && i.ExpiresAt < now)
.ToListAsync(cancellationToken);
@@ -54,7 +53,6 @@ namespace Musify.Infrastructure.Jobs
logger.LogInformation("Marked {Count} upload intents as Expired", expiredIntents.Count);
}
// Delete old Expired intents past retention window
if (uploadIntentConfiguration.ExpiredIntentsRetentionDays >= 0)
{
var retentionCutoff = now.AddDays(-uploadIntentConfiguration.ExpiredIntentsRetentionDays);