From 626c1e02cfabb4a2243ccbaf81c79e421d690789 Mon Sep 17 00:00:00 2001 From: radu-cernatescu Date: Mon, 6 Feb 2023 20:12:34 -0500 Subject: [PATCH] Fix: Refactor smb credentials dialog logic --- src/Files.App/Helpers/NavigationHelpers.cs | 22 -------------------- src/Files.App/ViewModels/ItemViewModel.cs | 8 +++++++ src/Files.App/ViewModels/ToolbarViewModel.cs | 7 ------- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/src/Files.App/Helpers/NavigationHelpers.cs b/src/Files.App/Helpers/NavigationHelpers.cs index 3230b4abf198..df93f22ce3f2 100644 --- a/src/Files.App/Helpers/NavigationHelpers.cs +++ b/src/Files.App/Helpers/NavigationHelpers.cs @@ -254,7 +254,6 @@ private static async Task OpenDirectory(string path, IShellPag var opened = (FilesystemResult)false; bool isHiddenItem = NativeFileOperationsHelper.HasFileAttribute(path, System.IO.FileAttributes.Hidden); bool isShortcut = FileExtensionHelpers.IsShortcutOrUrlFile(path); - bool isNetwork = path.StartsWith(@"\\", StringComparison.Ordinal); if (isShortcut) { @@ -274,27 +273,6 @@ private static async Task OpenDirectory(string path, IShellPag await OpenPath(forceOpenInNewTab, userSettingsService.FoldersSettingsService.OpenFoldersInNewTab, path, associatedInstance); opened = (FilesystemResult)true; } - else if (isNetwork) - { - var auth = await NetworkDrivesAPI.AuthenticateNetworkShare(path); - if (auth) - { - if (forceOpenInNewTab || userSettingsService.FoldersSettingsService.OpenFoldersInNewTab) - { - await OpenPathInNewTab(path); - } - else - { - associatedInstance.ToolbarViewModel.PathControlDisplayText = path; - associatedInstance.NavigateWithArguments(associatedInstance.InstanceViewModel.FolderSettings.GetLayoutType(path), new NavigationArguments() - { - NavPathParam = path, - AssociatedTabInstance = associatedInstance - }); - } - opened = (FilesystemResult)true; - } - } else { opened = await associatedInstance.FilesystemViewModel.GetFolderWithPathFromPathAsync(path) diff --git a/src/Files.App/ViewModels/ItemViewModel.cs b/src/Files.App/ViewModels/ItemViewModel.cs index b8e9e68f6dc5..51660b847373 100644 --- a/src/Files.App/ViewModels/ItemViewModel.cs +++ b/src/Files.App/ViewModels/ItemViewModel.cs @@ -1403,10 +1403,18 @@ public async Task EnumerateItemsFromStandardFolderAsync(string path, Cancel { // Flag to use FindFirstFileExFromApp or StorageFolder enumeration - Use storage folder for Box Drive (#4629) var isBoxFolder = App.CloudDrivesManager.Drives.FirstOrDefault(x => x.Text == "Box")?.Path?.TrimEnd('\\') is string boxFolder && path.StartsWith(boxFolder); + bool isNetwork = path.StartsWith(@"\\", StringComparison.Ordinal); bool enumFromStorageFolder = isBoxFolder; BaseStorageFolder? rootFolder = null; + if (isNetwork) + { + var auth = await NetworkDrivesAPI.AuthenticateNetworkShare(path); + if (!auth) + return -1; + } + if (!enumFromStorageFolder && FolderHelpers.CheckFolderAccessWithWin32(path)) { // Will enumerate with FindFirstFileExFromApp, rootFolder only used for Bitlocker diff --git a/src/Files.App/ViewModels/ToolbarViewModel.cs b/src/Files.App/ViewModels/ToolbarViewModel.cs index 1a1a6cdb8fff..edc6c74e7aab 100644 --- a/src/Files.App/ViewModels/ToolbarViewModel.cs +++ b/src/Files.App/ViewModels/ToolbarViewModel.cs @@ -955,13 +955,6 @@ public async Task CheckPathInput(string currentInput, string currentSelectedPath if (currentInput.StartsWith('\\') && !currentInput.StartsWith("\\\\", StringComparison.Ordinal)) currentInput = currentInput.Insert(0, "\\"); - if (currentInput.StartsWith('\\')) - { - var auth = await NetworkDrivesAPI.AuthenticateNetworkShare(currentInput); - if (!auth) - return; - } - if (currentSelectedPath == currentInput || string.IsNullOrWhiteSpace(currentInput)) return;