From 239727e8967c87610e4807b2b8051a3d33aac131 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Mon, 18 Mar 2024 16:09:00 +0100 Subject: fix: skip library folders that are inaccessible or empty (#9291) --- Emby.Server.Implementations/IO/ManagedFileSystem.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Emby.Server.Implementations/IO/ManagedFileSystem.cs') diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index c380d67db..67854a2a7 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Security; using Jellyfin.Extensions; using MediaBrowser.Common.Configuration; using MediaBrowser.Model.IO; @@ -643,7 +644,15 @@ namespace Emby.Server.Implementations.IO /// public virtual IEnumerable GetFileSystemEntryPaths(string path, bool recursive = false) { - return Directory.EnumerateFileSystemEntries(path, "*", GetEnumerationOptions(recursive)); + try + { + return Directory.EnumerateFileSystemEntries(path, "*", GetEnumerationOptions(recursive)); + } + catch (Exception ex) when (ex is UnauthorizedAccessException or DirectoryNotFoundException or SecurityException) + { + _logger.LogError(ex, "Failed to enumerate path {Path}", path); + return Enumerable.Empty(); + } } /// -- cgit v1.2.3