@@ -103,17 +103,24 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
103103 } ;
104104 }
105105
106+ // Log the contents of the root_preferences database to the debug output.
106107 await Inspect ( database , "SELECT * FROM roots" , "root_preferences db, roots table" ) ;
107108 await Inspect ( database , "SELECT * FROM media" , "root_preferences db, media table" ) ;
108109 await Inspect ( database , "SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY 1" , "root_preferences db, all tables" ) ;
109110
110- var registryPath = App . AppModel . GoogleDrivePath ;
111- if ( ! AddMyDriveToPathAndValidate ( ref registryPath ) )
111+ // Query the Windows Registry for the base Google Drive path and time the query.
112+ var sw = Stopwatch . StartNew ( ) ;
113+ var googleDrivePath = GetRegistryBasePath ( ) ?? string . Empty ;
114+ sw . Stop ( ) ;
115+ Debug . WriteLine ( $ "Google Drive path registry check took { sw . Elapsed } seconds.") ;
116+
117+ // Add "My Drive" to the base GD path; validate; return the resulting cloud provider.
118+ if ( ! AddMyDriveToPathAndValidate ( ref googleDrivePath ) )
112119 yield break ;
113120 yield return new CloudProvider ( CloudProviders . GoogleDrive )
114121 {
115122 Name = "Google Drive" ,
116- SyncFolder = registryPath ,
123+ SyncFolder = googleDrivePath ,
117124 IconData = iconFile is not null ? await iconFile . ToByteArrayAsync ( ) : null
118125 } ;
119126 }
@@ -164,6 +171,13 @@ private static async Task Inspect(SqliteConnection database, string sqlCommand,
164171 return googleDriveRegValueJson ;
165172 }
166173
174+ /// <summary>
175+ /// Get the base file system path for Google Drive from the Registry.
176+ /// </summary>
177+ /// <remarks>
178+ /// For advanced "Google Drive for desktop" settings reference, see:
179+ /// https://support.google.com/a/answer/7644837
180+ /// </remarks>
167181 public static string ? GetRegistryBasePath ( )
168182 {
169183 var googleDriveRegValJson = GetGoogleDriveRegValJson ( ) ;
@@ -175,8 +189,8 @@ private static async Task Inspect(SqliteConnection database, string sqlCommand,
175189 . RootElement . EnumerateObject ( )
176190 . FirstOrDefault ( ) ;
177191
178- // A default JsonProperty struct has an "Undefined" Value# ValueKind and throws an
179- // error if you try to call EnumerateArray on its Value .
192+ // A default " JsonProperty" struct has an undefined " Value. ValueKind" and throws an
193+ // error if you try to call " EnumerateArray" on its value .
180194 if ( googleDriveRegValJsonProperty . Value . ValueKind == JsonValueKind . Undefined )
181195 {
182196 _logger . LogWarning ( $ "Root element of Google Drive registry value for value name '{ _googleDriveRegValName } ' was empty.") ;
0 commit comments