Skip to content

Commit b2233de

Browse files
committed
issue #16149 different approach
Different approach to addressing the following issue: #16149 Use DriveHelpers.GetExtendedDriveLabel to safely get the VolumeLabel of each DriveInfo object that RemovableDrivesService looks at. Then use this to filter out GoogleDrive drives from appearing in a plain "Drives" section, while still (hopefully) allowing drives named "G" to appear in such a section. Next I will test this by renaming my Google Drive drive to something other than G, and then making a new drive that is not Google Drive and naming it "G", and then running the program to see if it detects the non-Google Drive "G" drive. next: testing
1 parent 74446b3 commit b2233de

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()
2424
var sw = Stopwatch.StartNew();
2525
var googleDrivePath = GoogleDriveCloudDetector.GetRegistryBasePath();
2626
sw.Stop();
27-
Debug.WriteLine($"In RemovableDrivesService: Time elapsed for registry check: {sw.Elapsed}");
27+
Debug.WriteLine($"In RemovableDrivesService: Time elapsed for Google Drive registry check: {sw.Elapsed}");
2828
var googleDrivePathWithMyDrive = googleDrivePath ?? string.Empty;
2929
var gdPathIsValid = GoogleDriveCloudDetector.AddMyDriveToPathAndValidate(ref googleDrivePathWithMyDrive);
3030
App.AppModel.GoogleDrivePath = gdPathIsValid ? googleDrivePathWithMyDrive : string.Empty;
3131

3232
foreach (var drive in list)
3333
{
34+
var driveLabel = DriveHelpers.GetExtendedDriveLabel(drive);
35+
Debug.WriteLine($"In RemovableDrivesService: Drive {drive.Name} has ExtendedDriveLabel `{driveLabel}`");
3436
// We don't want cloud drives to appear in a plain "Drives" section.
35-
if ((gdPathIsValid && drive.Name.Equals(googleDrivePath)) || drive.Name.Equals(pCloudDrivePath))
37+
if (driveLabel.Equals("Google Drive") || drive.Name.Equals(pCloudDrivePath))
3638
continue;
3739

3840
var res = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(drive.Name).AsTask());

0 commit comments

Comments
 (0)