Skip to content

Commit 7b62c45

Browse files
authored
Fix library update and list (#6426)
1 parent 8c4b871 commit 7b62c45

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

Files.Launcher/Helpers/ShellFolderHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static ShellLibraryItem GetShellLibraryItem(ShellLibrary library, string
2222
var folders = library.Folders;
2323
if (folders.Count > 0)
2424
{
25-
libraryItem.DefaultSaveFolder = library.DefaultSaveFolder.FileSystemPath;
25+
libraryItem.DefaultSaveFolder = Extensions.IgnoreExceptions(() => library.DefaultSaveFolder.FileSystemPath);
2626
libraryItem.Folders = folders.Select(f => f.FileSystemPath).ToArray();
2727
}
2828
return libraryItem;

Files.Launcher/MessageHandlers/LibrariesHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ private async Task HandleShellLibraryMessage(Dictionary<string, object> message)
195195
if (updated)
196196
{
197197
library.Commit();
198+
var libField = typeof(ShellLibrary).GetField("folders", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
199+
libField.SetValue(library, null); // Force library folder reload
198200
response.Add("Update", JsonConvert.SerializeObject(ShellFolderExtensions.GetShellLibraryItem(library, libPath)));
199201
}
200202
}

Files/Filesystem/LibraryManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public async Task<LibraryLocationItem> UpdateLibrary(string libraryPath, string
263263
var libItem = Libraries.FirstOrDefault(l => string.Equals(l.Path, libraryPath, StringComparison.OrdinalIgnoreCase));
264264
if (libItem != null)
265265
{
266-
Libraries[Libraries.IndexOf(libItem)] = libItem;
266+
Libraries[Libraries.IndexOf(libItem)] = newLib;
267267
}
268268
return newLib;
269269
}

Files/Views/Pages/PropertiesLibrary.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public override async Task<bool> SaveChangesAsync(ListedItem item)
189189
using var dialog = DynamicDialogFactory.GetFor_PropertySaveErrorDialog();
190190
try
191191
{
192-
var newLib = await App.LibraryManager.UpdateLibrary(props.Library.ItemPath, newDefaultSaveFolder, newFolders, newIsPinned);
192+
var newLib = await Task.Run(() => App.LibraryManager.UpdateLibrary(props.Library.ItemPath, newDefaultSaveFolder, newFolders, newIsPinned));
193193
if (newLib != null)
194194
{
195195
props.UpdateLibrary(new LibraryItem(newLib));

0 commit comments

Comments
 (0)