From baa30b41de59e32544422d0ead49cdf225448b54 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Mon, 2 Sep 2019 23:32:03 -0400 Subject: [PATCH] Add debug logs and try/catch when creating folder --- .../Library/LibraryManager.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 36934f65f0..87e951f25d 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -779,12 +779,23 @@ namespace Emby.Server.Implementations.Library { var userRootPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; + _logger.LogDebug("Creating userRootPath at {path}", userRootPath); Directory.CreateDirectory(userRootPath); - var tmpItem = GetItemById(GetNewItemId(userRootPath, typeof(UserRootFolder))) as UserRootFolder; + var newItemId = GetNewItemId(userRootPath, typeof(UserRootFolder)); + UserRootFolder tmpItem = null; + try + { + tmpItem = GetItemById(newItemId) as UserRootFolder; + } + catch (Exception ex) + { + _logger.LogError(ex, "Error creating UserRootFolder {path}", newItemId); + } if (tmpItem == null) { + _logger.LogDebug("Creating new userRootFolder with DeepCopy"); tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath))).DeepCopy(); } @@ -796,6 +807,7 @@ namespace Emby.Server.Implementations.Library } _userRootFolder = tmpItem; + _logger.LogDebug("Setting userRootFolder: {folder}", _userRootFolder); } } } @@ -1146,8 +1158,10 @@ namespace Emby.Server.Implementations.Library public List GetVirtualFolders(bool includeRefreshState) { + _logger.LogDebug("Getting topLibraryFolders"); var topLibraryFolders = GetUserRootFolder().Children.ToList(); + _logger.LogDebug("Getting refreshQueue"); var refreshQueue = includeRefreshState ? _providerManagerFactory().GetRefreshQueue() : null; return _fileSystem.GetDirectoryPaths(ConfigurationManager.ApplicationPaths.DefaultUserViewsPath)