mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-05-18 21:54:02 -04:00
Refactor and optimize audiobook download and decrypt process
- Add more null safety - Fix possible FilePathCache race condition - Add MoveFilesToBooksDir progress reporting - All metadata is now downloaded in parallel with other post-success tasks. - Improve download resuming and file cleanup reliability - The downloader creates temp files with a UUID filename and does not insert them into the FilePathCache. Created files only receive their final file names when they are moved into the Books folder. This is to prepare for a future plan re naming templates
This commit is contained in:
@@ -46,7 +46,9 @@ namespace LibationFileManager
|
||||
|
||||
public static List<(FileType fileType, LongPath path)> GetFiles(string id)
|
||||
{
|
||||
var matchingFiles = Cache.GetIdEntries(id);
|
||||
List<CacheEntry> matchingFiles;
|
||||
lock(locker)
|
||||
matchingFiles = Cache.GetIdEntries(id);
|
||||
|
||||
bool cacheChanged = false;
|
||||
|
||||
@@ -68,7 +70,9 @@ namespace LibationFileManager
|
||||
|
||||
public static LongPath? GetFirstPath(string id, FileType type)
|
||||
{
|
||||
var matchingFiles = Cache.GetIdEntries(id).Where(e => e.FileType == type).ToList();
|
||||
List<CacheEntry> matchingFiles;
|
||||
lock (locker)
|
||||
matchingFiles = Cache.GetIdEntries(id).Where(e => e.FileType == type).ToList();
|
||||
|
||||
bool cacheChanged = false;
|
||||
try
|
||||
@@ -96,7 +100,10 @@ namespace LibationFileManager
|
||||
|
||||
private static bool Remove(CacheEntry entry)
|
||||
{
|
||||
if (Cache.Remove(entry.Id, entry))
|
||||
bool removed;
|
||||
lock (locker)
|
||||
removed = Cache.Remove(entry.Id, entry);
|
||||
if (removed)
|
||||
{
|
||||
Removed?.Invoke(null, entry);
|
||||
return true;
|
||||
@@ -112,7 +119,8 @@ namespace LibationFileManager
|
||||
|
||||
public static void Insert(CacheEntry entry)
|
||||
{
|
||||
Cache.Add(entry.Id, entry);
|
||||
lock(locker)
|
||||
Cache.Add(entry.Id, entry);
|
||||
Inserted?.Invoke(null, entry);
|
||||
save();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user