fix cleanup of outdated files in filescanner

This commit is contained in:
rootdarkarchon
2022-11-15 20:55:38 +01:00
parent 605c1d3774
commit 14e5b5bb21
3 changed files with 9 additions and 3 deletions

View File

@@ -197,12 +197,13 @@ public class FileCacheManager : IDisposable
public void RemoveHash(FileCacheEntity entity)
{
FileCaches.Remove(entity.Hash, out _);
Logger.Verbose("Removing " + entity.ResolvedFilepath);
FileCaches.Remove(entity.PrefixedFilePath, out _);
}
public void UpdateHash(FileCacheEntity fileCache)
{
Logger.Debug("Updating hash for " + fileCache.ResolvedFilepath);
Logger.Verbose("Updating hash for " + fileCache.ResolvedFilepath);
fileCache.Hash = Crypto.GetFileHash(fileCache.ResolvedFilepath);
fileCache.LastModifiedDateTicks = new FileInfo(fileCache.ResolvedFilepath).LastWriteTimeUtc.Ticks.ToString(CultureInfo.InvariantCulture);
FileCaches.Remove(fileCache.PrefixedFilePath, out _);

View File

@@ -237,10 +237,12 @@ public class PeriodicFileScanner : IDisposable
scannedFiles[validatedCacheResult.Item2.ResolvedFilepath] = true;
if (validatedCacheResult.Item1 == FileState.RequireUpdate)
{
Logger.Verbose("To update: " + validatedCacheResult.Item2.ResolvedFilepath);
entitiesToUpdate.Add(validatedCacheResult.Item2);
}
else if (validatedCacheResult.Item1 == FileState.RequireDeletion)
{
Logger.Verbose("To delete: " + validatedCacheResult.Item2.ResolvedFilepath);
entitiesToRemove.Add(validatedCacheResult.Item2);
}
}

View File

@@ -68,7 +68,10 @@ public partial class ApiController
{
await wc.DownloadFileTaskAsync(downloadUri, fileName).ConfigureAwait(false);
}
catch { }
catch (Exception ex) {
Logger.Warn(ex.Message);
Logger.Warn(ex.StackTrace);
}
CurrentDownloads[downloadId].Single(f => string.Equals(f.Hash, hash, StringComparison.Ordinal)).Transferred = CurrentDownloads[downloadId].Single(f => string.Equals(f.Hash, hash, StringComparison.Ordinal)).Total;