From 6674a8ff2d4e988e76c841e52f88d2ad6eccf61b Mon Sep 17 00:00:00 2001 From: Saravanan Ganapathi Date: Fri, 21 Nov 2025 15:03:07 +0530 Subject: [PATCH] Feature: Hide drives without attached media from sidebar and homepage --- src/Files.App/Services/Storage/StorageDevicesService.cs | 3 +++ src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/Files.App/Services/Storage/StorageDevicesService.cs b/src/Files.App/Services/Storage/StorageDevicesService.cs index c29ca0b4f485..ab78cc0a635c 100644 --- a/src/Files.App/Services/Storage/StorageDevicesService.cs +++ b/src/Files.App/Services/Storage/StorageDevicesService.cs @@ -21,6 +21,9 @@ public async IAsyncEnumerable GetDrivesAsync() var pCloudDrivePath = App.AppModel.PCloudDrivePath; foreach (var drive in list) { + if (!drive.IsReady) + continue; + var driveLabel = DriveHelpers.GetExtendedDriveLabel(drive); // Filter out cloud drives // We don't want cloud drives to appear in the plain "Drives" sections. diff --git a/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs b/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs index 97c4dccbfd7d..dc813e6c2b31 100644 --- a/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs +++ b/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs @@ -52,6 +52,9 @@ private void Win32_OnDeviceRemoved(object? sender, DeviceEventArgs e) private async void Win32_OnDeviceAdded(object? sender, DeviceEventArgs e) { var driveAdded = new DriveInfo(e.DeviceId); + if (!driveAdded.IsReady) + return; + var rootAdded = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(e.DeviceId).AsTask()); if (!rootAdded) { @@ -98,6 +101,9 @@ private async void Watcher_Added(DeviceWatcher sender, DeviceInformation args) { // Check if this drive is associated with a drive letter var driveAdded = new DriveInfo(root.Path); + if (!driveAdded.IsReady) + return; + type = DriveHelpers.GetDriveType(driveAdded); label = DriveHelpers.GetExtendedDriveLabel(driveAdded); }