/// <summary> /// It's not really meant to be used this way, but this is our library /// "scanner". It scans the files and folders, and conditionally filters /// out _some_ of the files and/or folders. /// </summary> /// <param name="fileInfo"></param> /// <param name="parent"></param> /// <returns>True if the entry should be ignored.</returns> public bool ShouldIgnore(MediaBrowser.Model.IO.FileSystemMetadata fileInfo, BaseItem parent) { // Everything in the root folder is ignored by us. var root = LibraryManager.RootFolder; if (fileInfo == null || parent == null || root == null || parent == root || !(parent is Folder) || fileInfo.FullName.StartsWith(root.Path)) { return(false); } try { // Enable the scanner if we selected to use the Shoko provider for any metadata type on the current root folder. var libraryOptions = LibraryManager.GetLibraryOptions(parent); if (!libraryOptions.TypeOptions.Any(o => o.MetadataFetchers.Contains("Shoko"))) { return(false); } var fullPath = fileInfo.FullName; var rootFolder = ApiManager.FindMediaFolder(fullPath, parent as Folder, root); var partialPath = fullPath.Substring(rootFolder.Path.Length); if (fileInfo.IsDirectory) { return(ScanDirectory(partialPath, fullPath, LibraryManager.GetInheritedContentType(parent))); } else { return(ScanFile(partialPath, fullPath)); } } catch (System.Exception e) { if (!(e is System.Net.Http.HttpRequestException && e.Message.Contains("Connection refused"))) { Logger.LogError(e, $"Threw unexpectedly - {e.Message}"); } return(false); } }