mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-08-07 04:42:17 -04:00
Prevent crash if watched RootDirectory is deleted
This commit is contained in:
1 parent
bfee579719
commit
def0b1f611
2 files changed
+28
-18
No files matched your search
@@ -146,16 +146,7 @@ namespace LibationFileManager
|
||||
|
||||
protected override List<LongPath> GetFilePathsCustom(string productId)
|
||||
{
|
||||
// If user changed the BooksDirectory: reinitialize
|
||||
lock (bookDirectoryFilesLocker)
|
||||
{
|
||||
if (BooksDirectory != BookDirectoryFiles?.RootDirectory)
|
||||
{
|
||||
BookDirectoryFiles?.Dispose();
|
||||
BookDirectoryFiles = newBookDirectoryFiles();
|
||||
}
|
||||
}
|
||||
|
||||
ValidateBookDirectoryFiles();
|
||||
var regex = GetBookSearchRegex(productId);
|
||||
var diskFiles = BookDirectoryFiles?.FindFiles(regex) ?? [];
|
||||
|
||||
@@ -172,14 +163,25 @@ namespace LibationFileManager
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
lock (bookDirectoryFilesLocker)
|
||||
{
|
||||
BookDirectoryFiles ??= newBookDirectoryFiles();
|
||||
}
|
||||
|
||||
ValidateBookDirectoryFiles();
|
||||
BookDirectoryFiles?.RefreshFiles();
|
||||
}
|
||||
|
||||
private void ValidateBookDirectoryFiles()
|
||||
{
|
||||
lock (bookDirectoryFilesLocker)
|
||||
{
|
||||
if (BooksDirectory != BookDirectoryFiles?.RootDirectory)
|
||||
{
|
||||
//Will happen if the user changed the Books directory
|
||||
//or if BackgroundFileSystem errored out.
|
||||
BookDirectoryFiles?.Dispose();
|
||||
BookDirectoryFiles = newBookDirectoryFiles();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LongPath? GetPath(string productId) => GetFilePath(productId);
|
||||
|
||||
public static async IAsyncEnumerable<FilePathCache.CacheEntry> FindAudiobooksAsync(LongPath searchDirectory, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
|
||||
Reference in new issue
Block a user