Fix crash on unreadable root drive

This commit is contained in:
2023-11-03 10:42:30 +01:00
parent 17df1b45c2
commit 40df80b40f

View File

@@ -61,14 +61,23 @@ public class RootDriveInfoService : IRootDriveInfoService
private (DriveInfo Drive, IContainer? Item) GetContainer(DriveInfo rootDriveInfo) private (DriveInfo Drive, IContainer? Item) GetContainer(DriveInfo rootDriveInfo)
{ {
var task = Task.Run( var container = Task.Run(
async () => await _localContentProvider.GetItemByNativePathAsync( async () =>
new NativePath(rootDriveInfo.RootDirectory.FullName), {
PointInTime.Present) try
); {
task.Wait(); return await _localContentProvider.GetItemByNativePathAsync(
new NativePath(rootDriveInfo.RootDirectory.FullName),
return (rootDriveInfo, task.Result as IContainer); PointInTime.Present);
}
catch
{
return null;
}
}
).GetAwaiter().GetResult();
return (rootDriveInfo, container as IContainer);
} }
private static int GetDriveOrder(DriveType type) private static int GetDriveOrder(DriveType type)