Skip to content

Commit 1f5da1c

Browse files
committed
progress on #16149 -- cleanup (pre-PR)
StorageDevicesService Fix spacing of concatenated string that somehow got changed. GoogleDriveCloudDetector Change back to early yield break at end of `GetProviders` to reduce nesting. GoogleDriveCloudDetector Change `AddMyDriveToPathAndValidate` back to private. GoogleDriveCloudDetector Remove call stack logging from `AddMyDriveToPathAndValidate`.
1 parent f14e628 commit 1f5da1c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,22 @@ public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()
2323
foreach (var drive in list)
2424
{
2525
var driveLabel = DriveHelpers.GetExtendedDriveLabel(drive);
26-
// We don't want cloud drives to appear in a plain "Drives" section.
26+
// Cloud Drive Filter If (CDFI)
27+
// We don't want cloud drives to appear in the plain "Drives" sections.
2728
if (driveLabel.Equals("Google Drive") || drive.Name.Equals(pCloudDrivePath))
2829
continue;
2930

3031
var res = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(drive.Name).AsTask());
3132
if (res.ErrorCode is FileSystemStatusCode.Unauthorized)
3233
{
3334
App.Logger.LogWarning($"{res.ErrorCode}: Attempting to add the device, {drive.Name},"
34-
+ " failed at the StorageFolder initialization step. This device will be ignored.");
35+
+ " failed at the StorageFolder initialization step. This device will be ignored.");
3536
continue;
3637
}
3738
else if (!res)
3839
{
3940
App.Logger.LogWarning($"{res.ErrorCode}: Attempting to add the device, {drive.Name},"
40-
+ " failed at the StorageFolder initialization step. This device will be ignored.");
41+
+ " failed at the StorageFolder initialization step. This device will be ignored.");
4142
continue;
4243
}
4344

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
114114
sw.Stop();
115115
Debug.WriteLine($"Google Drive path registry check took {sw.Elapsed} seconds.");
116116

117-
// Add "My Drive" to the base GD path and return the resulting cloud provider.
118-
if (AddMyDriveToPathAndValidate(ref googleDrivePath))
119-
yield return new CloudProvider(CloudProviders.GoogleDrive)
120-
{
121-
Name = "Google Drive",
122-
SyncFolder = googleDrivePath,
123-
IconData = iconFile is not null ? await iconFile.ToByteArrayAsync() : null
124-
};
117+
// Add "My Drive" to the base GD path; validate; return the resulting cloud provider.
118+
if (!AddMyDriveToPathAndValidate(ref googleDrivePath))
119+
yield break;
120+
yield return new CloudProvider(CloudProviders.GoogleDrive)
121+
{
122+
Name = "Google Drive",
123+
SyncFolder = googleDrivePath,
124+
IconData = iconFile is not null ? await iconFile.ToByteArrayAsync() : null
125+
};
125126
}
126127

127128
private static async Task Inspect(SqliteConnection database, string sqlCommand, string targetDescription)
@@ -264,7 +265,7 @@ private static bool ValidatePath(string path)
264265
return await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());
265266
}
266267

267-
public static bool AddMyDriveToPathAndValidate(ref string path)
268+
private static bool AddMyDriveToPathAndValidate(ref string path)
268269
{
269270
// If `path` contains a shortcut named "My Drive", store its target in `shellFolderBaseFirst`.
270271
// This happens when "My Drive syncing options" is set to "Mirror files".
@@ -275,8 +276,7 @@ public static bool AddMyDriveToPathAndValidate(ref string path)
275276
si.Name?.Equals("My Drive") ?? false) as ShellLink)?.TargetPath
276277
?? string.Empty);
277278

278-
var callingMethod = new StackFrame(1).GetMethod();
279-
Debug.WriteLine($"SHELL FOLDER LOGGING (Context: `{callingMethod?.Name}` in `{callingMethod?.DeclaringType}`)");
279+
Debug.WriteLine("SHELL FOLDER LOGGING");
280280
rootFolder?.ForEach(si => Debug.WriteLine(si.Name));
281281

282282
if (!string.IsNullOrEmpty(myDriveFolder))

0 commit comments

Comments
 (0)