add raw filesize to db
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user