Replaced another id dependency with cache. Now safe for multi-file audiobooks. Also safe for current session not trying to move files created in a previous session or a parallel session of a different title

This commit is contained in:
Robert McRackan 2021-10-08 21:34:42 -04:00
parent c9a6c8fd35
commit df90094884
13 changed files with 258 additions and 221 deletions

View file

@ -10,7 +10,7 @@ namespace FileLiberator
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;
public event EventHandler<(string id, string path)> FileCreated;
protected void OnStreamingBegin(string filePath)
{
@ -34,11 +34,11 @@ namespace FileLiberator
StreamingCompleted?.Invoke(this, filePath);
}
protected void OnFileCreated(string productId, FileManager.FileType type, string path)
protected void OnFileCreated(string id, 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));
Serilog.Log.Logger.Information("File created {@DebugInfo}", new { Name = nameof(FileCreated), id, path });
FileManager.FilePathCache.Insert(id, path);
FileCreated?.Invoke(this, (id, path));
}
}
}