diff --git a/Source/FileManager/LongPath.cs b/Source/FileManager/LongPath.cs index 2175681a..956f46a4 100644 --- a/Source/FileManager/LongPath.cs +++ b/Source/FileManager/LongPath.cs @@ -163,6 +163,11 @@ namespace FileManager public override string ToString() => Path; + public override int GetHashCode() => Path.GetHashCode(); + public override bool Equals(object obj) => obj is LongPath other && Path == other.Path; + public static bool operator ==(LongPath path1, LongPath path2) => path1.Equals(path2); + public static bool operator !=(LongPath path1, LongPath path2) => !path1.Equals(path2); + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] private static extern int GetShortPathName([MarshalAs(UnmanagedType.LPWStr)] string path, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder shortPath, int shortPathLength); diff --git a/Source/LibationFileManager/AudibleFileStorage.cs b/Source/LibationFileManager/AudibleFileStorage.cs index ef07230d..34dc5b64 100644 --- a/Source/LibationFileManager/AudibleFileStorage.cs +++ b/Source/LibationFileManager/AudibleFileStorage.cs @@ -126,7 +126,16 @@ namespace LibationFileManager BookDirectoryFiles = new BackgroundFileSystem(BooksDirectory, "*.*", SearchOption.AllDirectories); var regex = GetBookSearchRegex(productId); - return BookDirectoryFiles.FindFiles(regex); + + //Find all extant files matching the priductID + //using both the file system and the file path cache + return + FilePathCache + .GetFiles(productId) + .Where(c => c.fileType == FileType.Audio && File.Exists(c.path)) + .Select(c => c.path) + .Union(BookDirectoryFiles.FindFiles(regex)) + .ToList(); } public void Refresh() => BookDirectoryFiles.RefreshFiles();