Skip to content

Commit 232d16d

Browse files
committed
switch to if; comments
Convert switch to if statement at end of AddMyDriveToPathAndValidate. Add some comments to explain the `shellFolderBase` code.
1 parent 3cc6444 commit 232d16d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,27 +310,30 @@ private bool AddMyDriveToPathAndValidate(ref string path, ILogger invalidPathsLo
310310
path = temp.RootDirectory.Name;
311311
}
312312

313+
// If `path` contains a shortcut named "My Drive", store its target in `shellFolderBaseFirst`.
314+
// This happens when "My Drive syncing options" is set to "Mirror files".
313315
using var shellFolderBase = ShellFolderExtensions.GetShellItemFromPathOrPIDL(path) as ShellFolder;
314316
var shellFolderBaseFirst = Environment.ExpandEnvironmentVariables((
315317
shellFolderBase?.FirstOrDefault(si =>
316318
si.Name?.Equals("My Drive") ??
317319
false) as ShellLink)
318320
?.TargetPath ??
319321
"");
322+
323+
// TESTING
320324
shellFolderBase?.ForEach(si => invalidPathsLogger.LogInformation(si.Name));
321325

322-
switch (shellFolderBaseFirst)
326+
if (!string.IsNullOrEmpty(shellFolderBaseFirst))
323327
{
324-
case "":
325-
path = Path.Combine(path, "My Drive");
326-
if (Directory.Exists(path))
327-
return true;
328-
_logger.LogWarning("Invalid Google Drive mount point path: " + path);
329-
return false;
330-
default:
331-
path = shellFolderBaseFirst;
332-
return true;
328+
path = shellFolderBaseFirst;
329+
return true;
333330
}
331+
332+
path = Path.Combine(path, "My Drive");
333+
if (Directory.Exists(path))
334+
return true;
335+
_logger.LogWarning("Invalid Google Drive mount point path: " + path);
336+
return false;
334337
}
335338
}
336339
}

0 commit comments

Comments
 (0)