add raw filesize to db

This commit is contained in:
Stanley Dimant
2024-09-04 16:53:05 +02:00
parent c2cc8e28f8
commit efe7fe98f2
6 changed files with 812 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
using ByteSizeLib;
using LZ4;
using MareSynchronosShared.Data;
using MareSynchronosShared.Metrics;
using MareSynchronosShared.Models;
@@ -262,6 +263,16 @@ public class MainFileCleanupService : IHostedService
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}
// only used if file in db has no raw size for whatever reason
if (!deleteCurrentFile && file != null && fileCache.RawSize == 0)
{
var length = LZ4Codec.Unwrap(File.ReadAllBytes(file.FullName)).LongLength;
_logger.LogInformation("Setting Raw File Size of " + fileCache.Hash + " to " + length);
fileCache.RawSize = length;
if (fileCounter % 1000 == 0)
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}
fileCounter++;
ct.ThrowIfCancellationRequested();