potentially fix stuck uploads

This commit is contained in:
rootdarkarchon
2023-01-18 19:46:03 +01:00
parent 20d8970a15
commit fe80faab6b
7 changed files with 577 additions and 21 deletions

View File

@@ -59,6 +59,8 @@ public class FileCleanupService : IHostedService
if (_isMainServer)
{
CleanUpStuckUploads(dbContext);
await dbContext.SaveChangesAsync(ct).ConfigureAwait(false);
}
@@ -72,6 +74,12 @@ public class FileCleanupService : IHostedService
}
}
private void CleanUpStuckUploads(MareDbContext dbContext)
{
var stuckUploads = dbContext.Files.Where(f => !f.Uploaded && f.UploadDate < DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(10)));
dbContext.Files.RemoveRange(stuckUploads);
}
private void CleanUpFilesBeyondSizeLimit(MareDbContext dbContext, CancellationToken ct)
{
var sizeLimit = _configuration.GetValueOrDefault<double>(nameof(StaticFilesServerConfiguration.CacheSizeHardLimitInGiB), -1);