From 5b3dc23f67f08f7bf9714fb996bede56eb9d6c95 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:37:10 +0000 Subject: [PATCH 1/2] Reliability: Handle exceptions when accessing Google Drive paths --- .../Detector/GoogleDriveCloudDetector.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs b/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs index f3ba712c2b18..959fbc855537 100644 --- a/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs +++ b/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs @@ -1,10 +1,14 @@ // Copyright (c) Files Community // Licensed under the MIT License. +using Files.App.Utils.Storage; +using Files.Shared.Extensions; using Microsoft.Data.Sqlite; using Microsoft.Extensions.Logging; using Microsoft.Win32; +using System.Diagnostics; using System.IO; +using System.Text.Json; using Vanara.Windows.Shell; using Windows.Storage; @@ -63,7 +67,14 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a path = path.Substring(@"\\?\".Length); } - var folder = await StorageFolder.GetFolderFromPathAsync(path); + var folderResult = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(path).AsTask()); + if (!folderResult) + { + _logger.LogWarning($"Could not access Google Drive path as local storage: {path}"); + continue; + } + + var folder = folderResult.Result; string title = reader["title"]?.ToString() ?? folder.Name; Debug.WriteLine("YIELD RETURNING from `GoogleDriveCloudDetector.GetProviders()` (roots): "); @@ -89,7 +100,14 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a if (!AddMyDriveToPathAndValidate(ref path)) continue; - var folder = await StorageFolder.GetFolderFromPathAsync(path); + var folderResult = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(path).AsTask()); + if (!folderResult) + { + _logger.LogWarning($"Could not access Google Drive path as local storage: {path}"); + continue; + } + + var folder = folderResult.Result; string title = reader["name"]?.ToString() ?? folder.Name; Debug.WriteLine("YIELD RETURNING from `GoogleDriveCloudDetector.GetProviders` (media): "); @@ -269,7 +287,8 @@ private static bool ValidatePath(string path) var iconPath = Path.Combine(programFilesEnvVar, "Google", "Drive File Stream", "drive_fs.ico"); - return await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask()); + var iconFileResult = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask()); + return iconFileResult ? iconFileResult.Result : null; } private static bool AddMyDriveToPathAndValidate(ref string path) From 46ce5a3e90e4c751429cdb1fd016a45fbc35d608 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 18 Aug 2025 16:02:51 -0400 Subject: [PATCH 2/2] Update GoogleDriveCloudDetector.cs --- .../Utils/Cloud/Detector/GoogleDriveCloudDetector.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs b/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs index 959fbc855537..502a4c4a1fa7 100644 --- a/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs +++ b/src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs @@ -1,14 +1,10 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.App.Utils.Storage; -using Files.Shared.Extensions; using Microsoft.Data.Sqlite; using Microsoft.Extensions.Logging; using Microsoft.Win32; -using System.Diagnostics; using System.IO; -using System.Text.Json; using Vanara.Windows.Shell; using Windows.Storage; @@ -73,7 +69,7 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a _logger.LogWarning($"Could not access Google Drive path as local storage: {path}"); continue; } - + var folder = folderResult.Result; string title = reader["title"]?.ToString() ?? folder.Name; @@ -106,7 +102,7 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a _logger.LogWarning($"Could not access Google Drive path as local storage: {path}"); continue; } - + var folder = folderResult.Result; string title = reader["name"]?.ToString() ?? folder.Name;