Calculate the hash while writing as well

This commit is contained in:
Loporrit
2025-03-15 00:00:47 +00:00
parent c7d8ba0ef0
commit 46053bf8fa
3 changed files with 100 additions and 7 deletions

View File

@@ -41,7 +41,7 @@ public sealed class FileCacheManager : IHostedService
private string CsvBakPath => _csvPath + ".bak";
public FileCacheEntity? CreateCacheEntry(string path)
public FileCacheEntity? CreateCacheEntry(string path, string? hash = null)
{
FileInfo fi = new(path);
if (!fi.Exists) return null;
@@ -49,7 +49,10 @@ public sealed class FileCacheManager : IHostedService
var fullName = fi.FullName.ToLowerInvariant();
if (!fullName.Contains(_configService.Current.CacheFolder.ToLowerInvariant(), StringComparison.Ordinal)) return null;
string prefixedPath = fullName.Replace(_configService.Current.CacheFolder.ToLowerInvariant(), CachePrefix + "\\", StringComparison.Ordinal).Replace("\\\\", "\\", StringComparison.Ordinal);
return CreateFileCacheEntity(fi, prefixedPath);
if (hash != null)
return CreateFileCacheEntity(fi, prefixedPath, hash);
else
return CreateFileCacheEntity(fi, prefixedPath);
}
public FileCacheEntity? CreateSubstEntry(string path)