Skip to content

Commit c28044a

Browse files
authored
Feature: Hide drives without attached media from sidebar and homepage (#17895)
1 parent da09d32 commit c28044a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Files.App/Services/Storage/StorageDevicesService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public async IAsyncEnumerable<IFolder> GetDrivesAsync()
2121
var pCloudDrivePath = App.AppModel.PCloudDrivePath;
2222
foreach (var drive in list)
2323
{
24+
if (!drive.IsReady)
25+
continue;
26+
2427
var driveLabel = DriveHelpers.GetExtendedDriveLabel(drive);
2528
// Filter out cloud drives
2629
// We don't want cloud drives to appear in the plain "Drives" sections.

src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ private void Win32_OnDeviceRemoved(object? sender, DeviceEventArgs e)
5252
private async void Win32_OnDeviceAdded(object? sender, DeviceEventArgs e)
5353
{
5454
var driveAdded = new DriveInfo(e.DeviceId);
55+
if (!driveAdded.IsReady)
56+
return;
57+
5558
var rootAdded = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(e.DeviceId).AsTask());
5659
if (!rootAdded)
5760
{
@@ -98,6 +101,9 @@ private async void Watcher_Added(DeviceWatcher sender, DeviceInformation args)
98101
{
99102
// Check if this drive is associated with a drive letter
100103
var driveAdded = new DriveInfo(root.Path);
104+
if (!driveAdded.IsReady)
105+
return;
106+
101107
type = DriveHelpers.GetDriveType(driveAdded);
102108
label = DriveHelpers.GetExtendedDriveLabel(driveAdded);
103109
}

0 commit comments

Comments
 (0)