diff --git a/LightlessSync/FileCache/FileCacheManager.cs b/LightlessSync/FileCache/FileCacheManager.cs index 51487f6..17f22de 100644 --- a/LightlessSync/FileCache/FileCacheManager.cs +++ b/LightlessSync/FileCache/FileCacheManager.cs @@ -260,6 +260,7 @@ public sealed class FileCacheManager : IHostedService { if (_fileCaches.TryGetValue(hash, out var caches)) { + _logger.LogTrace("Removing from DB: {hash} => {path}", hash, prefixedFilePath); var removedCount = caches?.RemoveAll(c => string.Equals(c.PrefixedFilePath, prefixedFilePath, StringComparison.Ordinal)); _logger.LogTrace("Removed from DB: {count} file(s) with hash {hash} and file cache {path}", removedCount, hash, prefixedFilePath); @@ -404,6 +405,12 @@ public sealed class FileCacheManager : IHostedService private FileCacheEntity? Validate(FileCacheEntity fileCache) { + if (string.IsNullOrWhiteSpace(fileCache.ResolvedFilepath)) + { + _logger.LogWarning("FileCacheEntity has empty ResolvedFilepath for hash {hash}, prefixed path {prefixed}", fileCache.Hash, fileCache.PrefixedFilePath); + RemoveHashedFile(fileCache.Hash, fileCache.PrefixedFilePath); + return null; + } var file = new FileInfo(fileCache.ResolvedFilepath); if (!file.Exists) {