Skip to content

Commit 607eb50

Browse files
Fix: Refactor smb credentials dialog logic (#11193)
1 parent 27cbf73 commit 607eb50

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

src/Files.App/Helpers/NavigationHelpers.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ private static async Task<FilesystemResult> OpenDirectory(string path, IShellPag
251251
var opened = (FilesystemResult)false;
252252
bool isHiddenItem = NativeFileOperationsHelper.HasFileAttribute(path, System.IO.FileAttributes.Hidden);
253253
bool isShortcut = FileExtensionHelpers.IsShortcutOrUrlFile(path);
254-
bool isNetwork = path.StartsWith(@"\\", StringComparison.Ordinal);
255254

256255
if (isShortcut)
257256
{
@@ -271,27 +270,6 @@ private static async Task<FilesystemResult> OpenDirectory(string path, IShellPag
271270
await OpenPath(forceOpenInNewTab, userSettingsService.FoldersSettingsService.OpenFoldersInNewTab, path, associatedInstance);
272271
opened = (FilesystemResult)true;
273272
}
274-
else if (isNetwork)
275-
{
276-
var auth = await NetworkDrivesAPI.AuthenticateNetworkShare(path);
277-
if (auth)
278-
{
279-
if (forceOpenInNewTab || userSettingsService.FoldersSettingsService.OpenFoldersInNewTab)
280-
{
281-
await OpenPathInNewTab(path);
282-
}
283-
else
284-
{
285-
associatedInstance.ToolbarViewModel.PathControlDisplayText = path;
286-
associatedInstance.NavigateWithArguments(associatedInstance.InstanceViewModel.FolderSettings.GetLayoutType(path), new NavigationArguments()
287-
{
288-
NavPathParam = path,
289-
AssociatedTabInstance = associatedInstance
290-
});
291-
}
292-
opened = (FilesystemResult)true;
293-
}
294-
}
295273
else
296274
{
297275
opened = await associatedInstance.FilesystemViewModel.GetFolderWithPathFromPathAsync(path)

src/Files.App/ViewModels/ItemViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,10 +1468,18 @@ public async Task<int> EnumerateItemsFromStandardFolderAsync(string path, Cancel
14681468
{
14691469
// Flag to use FindFirstFileExFromApp or StorageFolder enumeration - Use storage folder for Box Drive (#4629)
14701470
var isBoxFolder = App.CloudDrivesManager.Drives.FirstOrDefault(x => x.Text == "Box")?.Path?.TrimEnd('\\') is string boxFolder && path.StartsWith(boxFolder);
1471+
bool isNetwork = path.StartsWith(@"\\", StringComparison.Ordinal);
14711472
bool enumFromStorageFolder = isBoxFolder;
14721473

14731474
BaseStorageFolder? rootFolder = null;
14741475

1476+
if (isNetwork)
1477+
{
1478+
var auth = await NetworkDrivesAPI.AuthenticateNetworkShare(path);
1479+
if (!auth)
1480+
return -1;
1481+
}
1482+
14751483
if (!enumFromStorageFolder && FolderHelpers.CheckFolderAccessWithWin32(path))
14761484
{
14771485
// Will enumerate with FindFirstFileExFromApp, rootFolder only used for Bitlocker

src/Files.App/ViewModels/ToolbarViewModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,13 +1072,6 @@ public async Task CheckPathInput(string currentInput, string currentSelectedPath
10721072
if (currentInput.StartsWith('\\') && !currentInput.StartsWith("\\\\", StringComparison.Ordinal))
10731073
currentInput = currentInput.Insert(0, "\\");
10741074

1075-
if (currentInput.StartsWith('\\'))
1076-
{
1077-
var auth = await NetworkDrivesAPI.AuthenticateNetworkShare(currentInput);
1078-
if (!auth)
1079-
return;
1080-
}
1081-
10821075
if (currentSelectedPath == currentInput || string.IsNullOrWhiteSpace(currentInput))
10831076
return;
10841077

0 commit comments

Comments
 (0)