From 89317ee2c08e5edc3b43c7f35f1a44101077731f Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Mon, 4 Oct 2021 21:05:46 +0200 Subject: [PATCH 1/4] Skip inaccessible subkeys (#6212) --- Common/Extensions.cs | 26 +++++++++++++++++++ .../Cloud/Providers/MegaCloudProvider.cs | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Common/Extensions.cs b/Common/Extensions.cs index ea820f2fe5ac..3eb96e1804c1 100644 --- a/Common/Extensions.cs +++ b/Common/Extensions.cs @@ -119,5 +119,31 @@ public static async Task IgnoreExceptions(Func action, Logger logger return false; } } + + public static T IgnoreExceptions(Func action, Logger logger = null) + { + try + { + return action(); + } + catch (Exception ex) + { + logger?.Info(ex, ex.Message); + return default; + } + } + + public static async Task IgnoreExceptions(Func> action, Logger logger = null) + { + try + { + return await action(); + } + catch (Exception ex) + { + logger?.Info(ex, ex.Message); + return default; + } + } } } \ No newline at end of file diff --git a/Files/Filesystem/Cloud/Providers/MegaCloudProvider.cs b/Files/Filesystem/Cloud/Providers/MegaCloudProvider.cs index c09b7b6ed915..2e79c044c89b 100644 --- a/Files/Filesystem/Cloud/Providers/MegaCloudProvider.cs +++ b/Files/Filesystem/Cloud/Providers/MegaCloudProvider.cs @@ -27,8 +27,8 @@ private IList DetectFromRegistry() using var clsidKey = Registry.ClassesRoot.OpenSubKey(@"CLSID"); foreach (var subKeyName in clsidKey.GetSubKeyNames()) { - using var subKey = clsidKey.OpenSubKey(subKeyName); - if ((int?)subKey.GetValue("System.IsPinnedToNameSpaceTree") == 1) + using var subKey = Common.Extensions.IgnoreExceptions(() => clsidKey.OpenSubKey(subKeyName)); + if (subKey != null && (int?)subKey.GetValue("System.IsPinnedToNameSpaceTree") == 1) { using var namespaceKey = Registry.CurrentUser.OpenSubKey($@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{subKeyName}"); var driveType = (string)namespaceKey?.GetValue(""); From d7f3e939bcad4713c3b5f297e4714ab7a635a40f Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Mon, 4 Oct 2021 22:46:29 +0200 Subject: [PATCH 2/4] Show long path name (#6190) --- Files/App.xaml.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Files/App.xaml.cs b/Files/App.xaml.cs index 12cfc88be4d4..0d3c503b762c 100644 --- a/Files/App.xaml.cs +++ b/Files/App.xaml.cs @@ -304,6 +304,14 @@ protected override async void OnActivated(IActivatedEventArgs args) { async Task PerformNavigation(string payload) { + if (!string.IsNullOrEmpty(payload)) + { + var folder = (StorageFolder)await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(payload).AsTask()); + if (folder != null && !string.IsNullOrEmpty(folder.Path)) + { + payload = folder.Path; // Convert short name to long name (#6190) + } + } if (rootFrame.Content != null) { await MainPageViewModel.AddNewTabByPathAsync(typeof(PaneHolderPage), payload); From 569dedb05e1485dce981a3a1e058a83664952b18 Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Mon, 4 Oct 2021 22:47:30 +0200 Subject: [PATCH 3/4] Do not crash when setting contains slash (#6283) --- Files/DataModels/NavigationControlItems/LocationItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Files/DataModels/NavigationControlItems/LocationItem.cs b/Files/DataModels/NavigationControlItems/LocationItem.cs index 9b61ee1e45d9..119aab318b8b 100644 --- a/Files/DataModels/NavigationControlItems/LocationItem.cs +++ b/Files/DataModels/NavigationControlItems/LocationItem.cs @@ -46,10 +46,10 @@ public string Path public bool IsExpanded { - get => App.AppSettings.Get(Text == "SidebarFavorites".GetLocalized(), $"section:{Text}"); + get => App.AppSettings.Get(Text == "SidebarFavorites".GetLocalized(), $"section:{Text.Replace('\\', '_')}"); set { - App.AppSettings.Set(value, $"section:{Text}"); + App.AppSettings.Set(value, $"section:{Text.Replace('\\', '_')}"); OnPropertyChanged(nameof(IsExpanded)); } } From 11b130f428339000be6d043fdc6fc9fc14b7d7ba Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Mon, 4 Oct 2021 23:02:41 +0200 Subject: [PATCH 4/4] Show consent dialog if access to the C: is denied (#6272) --- Files/Filesystem/Drives.cs | 11 ++++------- Files/Views/ColumnShellPage.xaml.cs | 7 +++++-- Files/Views/ModernShellPage.xaml.cs | 7 +++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Files/Filesystem/Drives.cs b/Files/Filesystem/Drives.cs index f09a768e036a..53ddb00c75c2 100644 --- a/Files/Filesystem/Drives.cs +++ b/Files/Filesystem/Drives.cs @@ -61,14 +61,11 @@ public async Task EnumerateDrivesAsync() if (await GetDrivesAsync()) { - if (!Drives.Any(d => d.Type != DriveType.Removable)) + if (!Drives.Any(d => d.Type != DriveType.Removable && d.Path == "C:\\")) { - // Only show consent dialog if the exception is UnauthorizedAccessException - // and the drives list is empty (except for Removable drives which don't require FileSystem access) - await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => - { - ShowUserConsentOnInit = true; - }); + // Show consent dialog if the exception is UnauthorizedAccessException + // and the C: drive could not be accessed + ShowUserConsentOnInit = true; } } diff --git a/Files/Views/ColumnShellPage.xaml.cs b/Files/Views/ColumnShellPage.xaml.cs index 449a83c36daa..1fcebe5aa679 100644 --- a/Files/Views/ColumnShellPage.xaml.cs +++ b/Files/Views/ColumnShellPage.xaml.cs @@ -421,8 +421,11 @@ private async void DisplayFilesystemConsentDialog() if (App.DrivesManager?.ShowUserConsentOnInit ?? false) { App.DrivesManager.ShowUserConsentOnInit = false; - DynamicDialog dialog = DynamicDialogFactory.GetFor_ConsentDialog(); - await dialog.ShowAsync(ContentDialogPlacement.Popup); + await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => + { + DynamicDialog dialog = DynamicDialogFactory.GetFor_ConsentDialog(); + await dialog.ShowAsync(ContentDialogPlacement.Popup); + }); } } diff --git a/Files/Views/ModernShellPage.xaml.cs b/Files/Views/ModernShellPage.xaml.cs index 130aaef84524..b4a13a066df5 100644 --- a/Files/Views/ModernShellPage.xaml.cs +++ b/Files/Views/ModernShellPage.xaml.cs @@ -455,8 +455,11 @@ private async void DisplayFilesystemConsentDialog() if (App.DrivesManager?.ShowUserConsentOnInit ?? false) { App.DrivesManager.ShowUserConsentOnInit = false; - DynamicDialog dialog = DynamicDialogFactory.GetFor_ConsentDialog(); - await dialog.ShowAsync(ContentDialogPlacement.Popup); + await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => + { + DynamicDialog dialog = DynamicDialogFactory.GetFor_ConsentDialog(); + await dialog.ShowAsync(ContentDialogPlacement.Popup); + }); } }