New and moved files Upsert themselves in FileManager.FilePathCache

This commit is contained in:
Robert McRackan 2021-10-08 11:47:54 -04:00
parent 18cca53968
commit d0b78cc501
11 changed files with 149 additions and 144 deletions

View file

@ -9,6 +9,8 @@ namespace FileLiberator
public event EventHandler<DownloadProgress> StreamingProgressChanged;
public event EventHandler<TimeSpan> StreamingTimeRemaining;
public event EventHandler<string> StreamingCompleted;
/// <summary>Fired when a file is successfully saved to disk</summary>
public event EventHandler<(string id, FileManager.FileType type, string path)> FileCreated;
protected void OnStreamingBegin(string filePath)
{
@ -30,8 +32,13 @@ namespace FileLiberator
{
Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(StreamingCompleted), Message = filePath });
StreamingCompleted?.Invoke(this, filePath);
}
//TODO: Update file cache
protected void OnFileCreated(string productId, FileManager.FileType type, string path)
{
Serilog.Log.Logger.Information("File created {@DebugInfo}", new { Name = nameof(FileCreated), productId, TypeId = (int)type, TypeName = type.ToString(), path });
FileManager.FilePathCache.Upsert(productId, type, path);
FileCreated?.Invoke(this, (productId, type, path));
}
}
}