Repository: files-community/Files
File: src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs (C#)

Code before:
                );
            }

            return googleDriveRegValueJson;
        }

		private async IAsyncEnumerable<ICloudProvider> GetGoogleDriveProvidersFromRegistryAsync()
		{
            var googleDriveRegValJson = GetGoogleDriveRegValJson();

            if (googleDriveRegValJson is null)
				yield break;

			var googleDriveRegValJsonProperty = googleDriveRegValJson
				.RootElement.EnumerateObject()
				.FirstOrDefault();

			// A default JsonProperty struct has an "Undefined" Value#ValueKind and throws an
			// error if you try to call EnumerateArray on its Value.
			if (googleDriveRegValJsonProperty.Value.ValueKind == JsonValueKind.Undefined)
			{
				_logger.LogWarning(
					"Root element of Google Drive registry value for value name `"
						+ _googleDriveRegValName
						+ "' was empty."
				);
				yield break;
			}

#if DEBUG
			Debug.WriteLine("REGISTRY LOGGING");
			Debug.WriteLine(googleDriveRegValJsonProperty.ToString());
#endif

			foreach (var item in googleDriveRegValJsonProperty.Value.EnumerateArray())
			{
				if (!item.TryGetProperty(_googleDriveRegValPropName, out var googleDriveRegValProp))
					continue;

				if (!googleDriveRegValProp.TryGetProperty(_googleDriveRegValPropPropName,
					    out var googleDriveRegValPropProp))
					continue;

				var path = googleDriveRegValPropProp.GetString();
				if (path is null)
					continue;

				if (!AddMyDriveToPathAndValidate(ref path))
				{
					_logger.LogWarning("Validation failed for " + path + " (media)");
					continue;

Review comment (suggestion):
```suggestion
				_logger.LogWarning($"Root element of Google Drive registry value for value name '{_googleDriveRegValName}' was empty.");

```


Code after:
			{
				_logger.LogWarning($"Value from {_googleDriveRegValPropName} did not have property named {_googleDriveRegValPropPropName}");
				return null;
			}

			var path = googleDriveRegValPropProp.GetString();
			if (path is not null) 
				return ConvertDriveLetterToPathAndValidate(ref path) ? path : null;

			_logger.LogWarning($"Could not get string from value from {_googleDriveRegValPropPropName}");
			return null;
		}

		/// <summary>
		/// If Google Drive is mounted as a drive, then the path found in the registry will be
		/// *just* the drive letter (e.g. just "G" as opposed to "G:\"), and therefore must be
		/// reformatted as a valid path.
		/// </summary>
		private static bool ConvertDriveLetterToPathAndValidate(ref string path)
		{
			if (path.Length > 1) 
				return ValidatePath(path);

			DriveInfo driveInfo;
			try
			{
				driveInfo = new DriveInfo(path);
			}
			catch (ArgumentException e)
			{
				_logger.LogWarning(e, $"Could not resolve drive letter '{path}' to a valid drive.");
				return false;
			}

			path = driveInfo.RootDirectory.Name;
			return true;
		}

		private static bool ValidatePath(string path)
		{ 
			if (Directory.Exists(path))
				return true;
			_logger.LogWarning($"Invalid path: {path}");
			return false;
		}

		private static async Task<StorageFile?> GetGoogleDriveIconFileAsync()
		{
			var programFilesEnvVar = Environment.GetEnvironmentVariable("ProgramFiles");

			if (programFilesEnvVar is null)