Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Common/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,31 @@ public static async Task<bool> IgnoreExceptions(Func<Task> action, Logger logger
return false;
}
}

public static T IgnoreExceptions<T>(Func<T> action, Logger logger = null)
{
try
{
return action();
}
catch (Exception ex)
{
logger?.Info(ex, ex.Message);
return default;
}
}

public static async Task<T> IgnoreExceptions<T>(Func<Task<T>> action, Logger logger = null)
{
try
{
return await action();
}
catch (Exception ex)
{
logger?.Info(ex, ex.Message);
return default;
}
}
}
}
8 changes: 8 additions & 0 deletions Files/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Files/DataModels/NavigationControlItems/LocationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
4 changes: 2 additions & 2 deletions Files/Filesystem/Cloud/Providers/MegaCloudProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ private IList<CloudProvider> 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("");
Expand Down
11 changes: 4 additions & 7 deletions Files/Filesystem/Drives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
7 changes: 5 additions & 2 deletions Files/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

Expand Down
7 changes: 5 additions & 2 deletions Files/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

Expand Down