Improve finding audio file by ID
This commit is contained in:
parent
5219ad53e1
commit
bb05847b25
@ -163,6 +163,11 @@ namespace FileManager
|
|||||||
|
|
||||||
public override string ToString() => Path;
|
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)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||||
private static extern int GetShortPathName([MarshalAs(UnmanagedType.LPWStr)] string path, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder shortPath, int shortPathLength);
|
private static extern int GetShortPathName([MarshalAs(UnmanagedType.LPWStr)] string path, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder shortPath, int shortPathLength);
|
||||||
|
|||||||
@ -126,7 +126,16 @@ namespace LibationFileManager
|
|||||||
BookDirectoryFiles = new BackgroundFileSystem(BooksDirectory, "*.*", SearchOption.AllDirectories);
|
BookDirectoryFiles = new BackgroundFileSystem(BooksDirectory, "*.*", SearchOption.AllDirectories);
|
||||||
|
|
||||||
var regex = GetBookSearchRegex(productId);
|
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();
|
public void Refresh() => BookDirectoryFiles.RefreshFiles();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user