Skip to content

Commit c48ed0f

Browse files
authored
Fix crash when creating folders in libraries (#5793)
1 parent ac1e63c commit c48ed0f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Files/Helpers/UIFilesystemHelpers.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ public static async Task<IStorageItem> CreateFileFromDialogResultTypeForResult(A
221221
if (associatedInstance.SlimContentPage != null)
222222
{
223223
currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory;
224+
if (App.LibraryManager.TryGetLibrary(currentPath, out var library))
225+
{
226+
if (!library.IsEmpty && library.Folders.Count == 1) // TODO: handle libraries with multiple folders
227+
{
228+
currentPath = library.Folders.First();
229+
}
230+
}
224231
}
225232

226233
// Show rename dialog
@@ -235,7 +242,7 @@ public static async Task<IStorageItem> CreateFileFromDialogResultTypeForResult(A
235242
// Create file based on dialog result
236243
string userInput = dialog.ViewModel.AdditionalData as string;
237244
var folderRes = await associatedInstance.FilesystemViewModel.GetFolderWithPathFromPathAsync(currentPath);
238-
FilesystemResult<(ReturnResult, IStorageItem)> created = null;
245+
var created = new FilesystemResult<(ReturnResult, IStorageItem)>((ReturnResult.Failed, null), FileSystemStatusCode.Generic);
239246
if (folderRes)
240247
{
241248
switch (itemType)

0 commit comments

Comments
 (0)