add try catch to the initial file rawsize calc
This commit is contained in:
@@ -243,6 +243,23 @@ public class MainFileCleanupService : IHostedService
|
|||||||
deleteCurrentFile = true;
|
deleteCurrentFile = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only used if file in db has no raw size for whatever reason
|
||||||
|
if (!deleteCurrentFile && file != null && fileCache.RawSize == 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Could not unpack {fileName}", file.FullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// do actual deletion of file and remove also from db if needed
|
// do actual deletion of file and remove also from db if needed
|
||||||
if (deleteCurrentFile)
|
if (deleteCurrentFile)
|
||||||
{
|
{
|
||||||
@@ -263,16 +280,6 @@ public class MainFileCleanupService : IHostedService
|
|||||||
await dbContext.SaveChangesAsync().ConfigureAwait(false);
|
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++;
|
fileCounter++;
|
||||||
|
|
||||||
ct.ThrowIfCancellationRequested();
|
ct.ThrowIfCancellationRequested();
|
||||||
|
|||||||
Reference in New Issue
Block a user