Skip to content

Commit 729485c

Browse files
committed
Do not req pw when navigating up
1 parent dfcb2fc commit 729485c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/Files.App/Filesystem/StorageFileHelpers/StorageFileExtensions.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,15 @@ public async static Task<StorageFileWithPath> DangerousGetFileWithPathFromPathAs
190190
}
191191
}
192192

193-
if (parentFolder is not null && !Path.IsPathRooted(value) && !ShellStorageFolder.IsShellPath(value)) // "::{" not a valid root
194-
{
195-
// Relative path
196-
var fullPath = Path.GetFullPath(Path.Combine(parentFolder.Path, value));
197-
return new StorageFileWithPath(await BaseStorageFile.GetFileFromPathAsync(fullPath));
198-
}
199-
return new StorageFileWithPath(await BaseStorageFile.GetFileFromPathAsync(value));
193+
var fullPath = (parentFolder is not null && !Path.IsPathRooted(value) && !ShellStorageFolder.IsShellPath(value)) // "::{" not a valid root
194+
? Path.GetFullPath(Path.Combine(parentFolder.Path, value)) // Relative path
195+
: value;
196+
var item = await BaseStorageFile.GetFileFromPathAsync(fullPath);
197+
198+
if (parentFolder is not null && parentFolder.Path.IsSubPathOf(value) && parentFolder.Item is IPasswordProtectedItem ppis && item is IPasswordProtectedItem ppid)
199+
ppid.Credentials = ppis.Credentials;
200+
201+
return new StorageFileWithPath(item);
200202
}
201203
public async static Task<IList<StorageFileWithPath>> GetFilesWithPathAsync
202204
(this StorageFolderWithPath parentFolder, uint maxNumberOfItems = uint.MaxValue)
@@ -242,16 +244,15 @@ public async static Task<StorageFolderWithPath> DangerousGetFolderWithPathFromPa
242244
}
243245
}
244246

245-
if (parentFolder is not null && !Path.IsPathRooted(value) && !ShellStorageFolder.IsShellPath(value)) // "::{" not a valid root
246-
{
247-
// Relative path
248-
var fullPath = Path.GetFullPath(Path.Combine(parentFolder.Path, value));
249-
return new StorageFolderWithPath(await BaseStorageFolder.GetFolderFromPathAsync(fullPath));
250-
}
251-
else
252-
{
253-
return new StorageFolderWithPath(await BaseStorageFolder.GetFolderFromPathAsync(value));
254-
}
247+
var fullPath = (parentFolder is not null && !Path.IsPathRooted(value) && !ShellStorageFolder.IsShellPath(value)) // "::{" not a valid root
248+
? Path.GetFullPath(Path.Combine(parentFolder.Path, value)) // Relative path
249+
: value;
250+
var item = await BaseStorageFolder.GetFolderFromPathAsync(fullPath);
251+
252+
if (parentFolder is not null && parentFolder.Path.IsSubPathOf(value) && parentFolder.Item is IPasswordProtectedItem ppis && item is IPasswordProtectedItem ppid)
253+
ppid.Credentials = ppis.Credentials;
254+
255+
return new StorageFolderWithPath(item);
255256
}
256257
public async static Task<IList<StorageFolderWithPath>> GetFoldersWithPathAsync
257258
(this StorageFolderWithPath parentFolder, uint maxNumberOfItems = uint.MaxValue)

0 commit comments

Comments
 (0)