@@ -72,6 +72,7 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
72
72
App . AppModel . GoogleDrivePath = path ;
73
73
74
74
#if DEBUG
75
+ Debug . WriteLine ( $ "In GDCD in roots table: App.AppModel.GoogleDrivePath being set to: { path } ") ;
75
76
Debug . WriteLine ( "YIELD RETURNING from GoogleDriveCloudDetector#GetProviders (roots): " ) ;
76
77
Debug . WriteLine ( $ "name=Google Drive ({ title } ); path={ path } ") ;
77
78
#endif
@@ -106,6 +107,7 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
106
107
var iconFile = await GetGoogleDriveIconFileAsync ( ) ;
107
108
108
109
#if DEBUG
110
+ Debug . WriteLine ( $ "In GDCD in media table: App.AppModel.GoogleDrivePath being set to: { path } ") ;
109
111
Debug . WriteLine ( "YIELD RETURNING from GoogleDriveCloudDetector#GetProviders (media): " ) ;
110
112
Debug . WriteLine ( $ "name={ title } ; path={ path } ") ;
111
113
#endif
@@ -160,7 +162,7 @@ private async Task Inspect(SqliteConnection database, string sqlCommand, string
160
162
#endif
161
163
}
162
164
163
- private JsonDocument ? GetGoogleDriveRegValJson ( )
165
+ private static JsonDocument ? GetGoogleDriveRegValJson ( )
164
166
{
165
167
// This will be null if the key name is not found.
166
168
using var googleDriveRegKey = Registry . CurrentUser . OpenSubKey ( _googleDriveRegKeyName ) ;
@@ -192,7 +194,7 @@ private async Task Inspect(SqliteConnection database, string sqlCommand, string
192
194
return googleDriveRegValueJson ;
193
195
}
194
196
195
- private async IAsyncEnumerable < ICloudProvider > GetGoogleDriveProvidersFromRegistryAsync ( )
197
+ public static async IAsyncEnumerable < ICloudProvider > GetGoogleDriveProvidersFromRegistryAsync ( bool addMyDriveToPath = true )
196
198
{
197
199
var googleDriveRegValJson = GetGoogleDriveRegValJson ( ) ;
198
200
@@ -228,13 +230,16 @@ private async IAsyncEnumerable<ICloudProvider> GetGoogleDriveProvidersFromRegist
228
230
if ( path is null )
229
231
continue ;
230
232
231
- if ( ! AddMyDriveToPathAndValidate ( ref path ) )
233
+ if ( ! AddMyDriveToPathAndValidate ( ref path , addMyDriveToPath ) )
232
234
{
233
235
_logger . LogWarning ( $ "Validation failed for { path } (media)") ;
234
236
continue ;
235
237
}
236
238
237
239
App . AppModel . GoogleDrivePath = path ;
240
+ #if DEBUG
241
+ Debug . WriteLine ( $ "In GDCD in registry: App.AppModel.GoogleDrivePath being set to: { path } ") ;
242
+ #endif
238
243
239
244
var iconFile = await GetGoogleDriveIconFileAsync ( ) ;
240
245
@@ -247,7 +252,7 @@ private async IAsyncEnumerable<ICloudProvider> GetGoogleDriveProvidersFromRegist
247
252
}
248
253
}
249
254
250
- private async Task < StorageFile ? > GetGoogleDriveIconFileAsync ( )
255
+ private static async Task < StorageFile ? > GetGoogleDriveIconFileAsync ( )
251
256
{
252
257
var programFilesEnvVar = Environment . GetEnvironmentVariable ( "ProgramFiles" ) ;
253
258
@@ -259,7 +264,7 @@ private async IAsyncEnumerable<ICloudProvider> GetGoogleDriveProvidersFromRegist
259
264
return await FilesystemTasks . Wrap ( ( ) => StorageFile . GetFileFromPathAsync ( iconPath ) . AsTask ( ) ) ;
260
265
}
261
266
262
- private bool AddMyDriveToPathAndValidate ( ref string path )
267
+ private static bool AddMyDriveToPathAndValidate ( ref string path , bool addMyDrive = true )
263
268
{
264
269
// If Google Drive is mounted as a drive, then the path found in the registry will be
265
270
// *just* the drive letter (e.g. just "G" as opposed to "G:\"), and therefore must be
@@ -280,27 +285,31 @@ private bool AddMyDriveToPathAndValidate(ref string path)
280
285
path = temp . RootDirectory . Name ;
281
286
}
282
287
283
- // If `path` contains a shortcut named "My Drive", store its target in `shellFolderBaseFirst`.
284
- // This happens when "My Drive syncing options" is set to "Mirror files".
285
- // TODO: Avoid to use Vanara (#15000)
286
- using var shellFolderBase = ShellFolderExtensions . GetShellItemFromPathOrPIDL ( path ) as ShellFolder ;
287
- var shellFolderBaseFirst = Environment . ExpandEnvironmentVariables ( (
288
- shellFolderBase ? . FirstOrDefault ( si =>
289
- si . Name ? . Equals ( "My Drive" ) ?? false ) as ShellLink ) ? . TargetPath
290
- ?? string . Empty ) ;
288
+ if ( addMyDrive )
289
+ {
290
+ // If `path` contains a shortcut named "My Drive", store its target in `shellFolderBaseFirst`.
291
+ // This happens when "My Drive syncing options" is set to "Mirror files".
292
+ // TODO: Avoid to use Vanara (#15000)
293
+ using var shellFolderBase = ShellFolderExtensions . GetShellItemFromPathOrPIDL ( path ) as ShellFolder ;
294
+ var shellFolderBaseFirst = Environment . ExpandEnvironmentVariables ( (
295
+ shellFolderBase ? . FirstOrDefault ( si =>
296
+ si . Name ? . Equals ( "My Drive" ) ?? false ) as ShellLink ) ? . TargetPath
297
+ ?? string . Empty ) ;
291
298
292
299
#if DEBUG
293
- Debug . WriteLine ( "INVALID PATHS LOGGER" ) ;
294
- shellFolderBase ? . ForEach ( si => Debug . WriteLine ( si . Name ) ) ;
300
+ Debug . WriteLine ( "INVALID PATHS LOGGER" ) ;
301
+ shellFolderBase ? . ForEach ( si => Debug . WriteLine ( si . Name ) ) ;
295
302
#endif
296
303
297
- if ( ! string . IsNullOrEmpty ( shellFolderBaseFirst ) )
298
- {
299
- path = shellFolderBaseFirst ;
300
- return true ;
304
+ if ( ! string . IsNullOrEmpty ( shellFolderBaseFirst ) )
305
+ {
306
+ path = shellFolderBaseFirst ;
307
+ return true ;
308
+ }
309
+
310
+ path = Path . Combine ( path , "My Drive" ) ;
301
311
}
302
312
303
- path = Path . Combine ( path , "My Drive" ) ;
304
313
if ( Directory . Exists ( path ) )
305
314
return true ;
306
315
_logger . LogWarning ( $ "Invalid Google Drive mount point path: { path } ") ;
0 commit comments