From 16fe8305d16600eba800a88fe2ddd9ace6b78087 Mon Sep 17 00:00:00 2001 From: Radekor500 Date: Sat, 24 Feb 2024 14:20:56 +0100 Subject: [PATCH] add removing from tracker service to background file service --- .../BackgroundTasks/BackgroundFailedUploadRemoverService.cs | 2 +- .../BackgroundTasks/BackgroundFileService.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/SecureSend.Infrastructure/BackgroundTasks/BackgroundFailedUploadRemoverService.cs b/SecureSend.Infrastructure/BackgroundTasks/BackgroundFailedUploadRemoverService.cs index 60924ad..cf7a8c9 100644 --- a/SecureSend.Infrastructure/BackgroundTasks/BackgroundFailedUploadRemoverService.cs +++ b/SecureSend.Infrastructure/BackgroundTasks/BackgroundFailedUploadRemoverService.cs @@ -29,7 +29,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) { using var scope = _serviceProvider.CreateScope(); await RemoveFailedUploads(scope, stoppingToken); - await Task.Delay(TimeSpan.FromMinutes(2), stoppingToken); + await Task.Delay(TimeSpan.FromMinutes(30), stoppingToken); } } diff --git a/SecureSend.Infrastructure/BackgroundTasks/BackgroundFileService.cs b/SecureSend.Infrastructure/BackgroundTasks/BackgroundFileService.cs index 485a027..7243fb3 100644 --- a/SecureSend.Infrastructure/BackgroundTasks/BackgroundFileService.cs +++ b/SecureSend.Infrastructure/BackgroundTasks/BackgroundFileService.cs @@ -36,9 +36,11 @@ private async Task RemoveExpiredUploads(CancellationToken token) var query = dbContext.SecureSendUploads.Where(u => u.ExpiryDate < DateTime.UtcNow); var expiredUploads = await query.AsNoTracking().ToListAsync(token); + var trackerService = scope.ServiceProvider.GetRequiredService(); foreach (var upload in expiredUploads) { fileService.RemoveUpload(upload.Id); + trackerService.Remove(upload.Id); _logger.LogInformation("Removing expired upload: {@id}", upload.Id); }