Skip to content

Commit bc97433

Browse files
authored
Fix: Fixed UnauthorizedAccessException in LibraryManager.OnLibraryChanged (#17376)
1 parent b478218 commit bc97433

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Files.App/Utils/Library/LibraryManager.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,12 @@ private void OnLibraryChanged(WatcherChangeTypes changeType, string oldPath, str
382382
return;
383383
}
384384

385-
var library1 = ShellFolderExtensions.GetShellLibraryItem(library, newPath);
385+
var library1 = SafetyExtensions.IgnoreExceptions(() => ShellFolderExtensions.GetShellLibraryItem(library, newPath));
386+
if (library1 is null)
387+
{
388+
App.Logger.LogWarning($"Failed to open library after {changeType}: {newPath}");
389+
return;
390+
}
386391

387392
string? path = oldPath;
388393
if (string.IsNullOrEmpty(oldPath))

0 commit comments

Comments
 (0)