@@ -103,17 +103,24 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
103
103
} ;
104
104
}
105
105
106
+ // Log the contents of the root_preferences database to the debug output.
106
107
await Inspect ( database , "SELECT * FROM roots" , "root_preferences db, roots table" ) ;
107
108
await Inspect ( database , "SELECT * FROM media" , "root_preferences db, media table" ) ;
108
109
await Inspect ( database , "SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY 1" , "root_preferences db, all tables" ) ;
109
110
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 ) )
112
119
yield break ;
113
120
yield return new CloudProvider ( CloudProviders . GoogleDrive )
114
121
{
115
122
Name = "Google Drive" ,
116
- SyncFolder = registryPath ,
123
+ SyncFolder = googleDrivePath ,
117
124
IconData = iconFile is not null ? await iconFile . ToByteArrayAsync ( ) : null
118
125
} ;
119
126
}
@@ -164,6 +171,13 @@ private static async Task Inspect(SqliteConnection database, string sqlCommand,
164
171
return googleDriveRegValueJson ;
165
172
}
166
173
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>
167
181
public static string ? GetRegistryBasePath ( )
168
182
{
169
183
var googleDriveRegValJson = GetGoogleDriveRegValJson ( ) ;
@@ -175,8 +189,8 @@ private static async Task Inspect(SqliteConnection database, string sqlCommand,
175
189
. RootElement . EnumerateObject ( )
176
190
. FirstOrDefault ( ) ;
177
191
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 .
180
194
if ( googleDriveRegValJsonProperty . Value . ValueKind == JsonValueKind . Undefined )
181
195
{
182
196
_logger . LogWarning ( $ "Root element of Google Drive registry value for value name '{ _googleDriveRegValName } ' was empty.") ;
0 commit comments