Skip to content

Commit 74446b3

Browse files
committed
address issue #16149
Address the following issue: #16149 Avoid skipping detection of a drive named G that is not Google Drive when the registry contains old keys for Google Drive. Add "My Drive" to the Google Drive registry path in RemovableDrivesService and check if it's valid. Then DON'T skip the found "G" drive if the "My Drive" path is NOT valid.
1 parent 7a45c4e commit 74446b3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,27 @@ public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()
2525
var googleDrivePath = GoogleDriveCloudDetector.GetRegistryBasePath();
2626
sw.Stop();
2727
Debug.WriteLine($"In RemovableDrivesService: Time elapsed for registry check: {sw.Elapsed}");
28-
App.AppModel.GoogleDrivePath = googleDrivePath ?? string.Empty;
28+
var googleDrivePathWithMyDrive = googleDrivePath ?? string.Empty;
29+
var gdPathIsValid = GoogleDriveCloudDetector.AddMyDriveToPathAndValidate(ref googleDrivePathWithMyDrive);
30+
App.AppModel.GoogleDrivePath = gdPathIsValid ? googleDrivePathWithMyDrive : string.Empty;
2931

3032
foreach (var drive in list)
3133
{
3234
// We don't want cloud drives to appear in a plain "Drives" section.
33-
if (drive.Name.Equals(googleDrivePath) || drive.Name.Equals(pCloudDrivePath))
35+
if ((gdPathIsValid && drive.Name.Equals(googleDrivePath)) || drive.Name.Equals(pCloudDrivePath))
3436
continue;
3537

3638
var res = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(drive.Name).AsTask());
3739
if (res.ErrorCode is FileSystemStatusCode.Unauthorized)
3840
{
3941
App.Logger.LogWarning($"{res.ErrorCode}: Attempting to add the device, {drive.Name},"
40-
+ " failed at the StorageFolder initialization step. This device will be ignored.");
42+
+ " failed at the StorageFolder initialization step. This device will be ignored.");
4143
continue;
4244
}
4345
else if (!res)
4446
{
4547
App.Logger.LogWarning($"{res.ErrorCode}: Attempting to add the device, {drive.Name},"
46-
+ " failed at the StorageFolder initialization step. This device will be ignored.");
48+
+ " failed at the StorageFolder initialization step. This device will be ignored.");
4749
continue;
4850
}
4951

src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
108108
await Inspect(database, "SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY 1", "root_preferences db, all tables");
109109

110110
var registryPath = App.AppModel.GoogleDrivePath;
111-
if (!AddMyDriveToPathAndValidate(ref registryPath))
111+
if (registryPath.Equals(string.Empty))
112112
yield break;
113113
yield return new CloudProvider(CloudProviders.GoogleDrive)
114114
{
@@ -258,7 +258,7 @@ private static bool ValidatePath(string path)
258258
return await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());
259259
}
260260

261-
private static bool AddMyDriveToPathAndValidate(ref string path)
261+
public static bool AddMyDriveToPathAndValidate(ref string path)
262262
{
263263
// If `path` contains a shortcut named "My Drive", store its target in `shellFolderBaseFirst`.
264264
// This happens when "My Drive syncing options" is set to "Mirror files".

0 commit comments

Comments
 (0)