aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs55
1 files changed, 35 insertions, 20 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 9d66455e7..712ea4ef3 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -33,6 +33,7 @@ using System.Net;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
+using MediaBrowser.Controller.Channels;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Extensions;
@@ -353,10 +354,6 @@ namespace MediaBrowser.Server.Implementations.Library
private void RegisterItem(Guid id, BaseItem item)
{
- if (item.SourceType != SourceType.Library)
- {
- return;
- }
if (item is IItemByName)
{
if (!(item is MusicArtist))
@@ -364,14 +361,25 @@ namespace MediaBrowser.Server.Implementations.Library
return;
}
}
- if (item is Photo)
+
+ if (item.IsFolder)
{
- return;
+ if (!(item is ICollectionFolder) && !(item is UserView) && !(item is Channel))
+ {
+ if (item.SourceType != SourceType.Library)
+ {
+ return;
+ }
+ }
+ }
+ else
+ {
+ if (item is Photo)
+ {
+ return;
+ }
}
- //if (!(item is Folder))
- //{
- // return;
- //}
+
LibraryItemsCache.AddOrUpdate(id, item, delegate { return item; });
}
@@ -782,19 +790,19 @@ namespace MediaBrowser.Server.Implementations.Library
public BaseItem FindByPath(string path, bool? isFolder)
{
+ // If this returns multiple items it could be tricky figuring out which one is correct.
+ // In most cases, the newest one will be and the others obsolete but not yet cleaned up
+
var query = new InternalItemsQuery
{
Path = path,
- IsFolder = isFolder
+ IsFolder = isFolder,
+ SortBy = new[] { ItemSortBy.DateCreated },
+ SortOrder = SortOrder.Descending,
+ Limit = 1
};
- // If this returns multiple items it could be tricky figuring out which one is correct.
- // In most cases, the newest one will be and the others obsolete but not yet cleaned up
-
- return GetItemIds(query)
- .Select(GetItemById)
- .Where(i => i != null)
- .OrderByDescending(i => i.DateCreated)
+ return GetItemList(query)
.FirstOrDefault();
}
@@ -1258,6 +1266,8 @@ namespace MediaBrowser.Server.Implementations.Library
item = RetrieveItem(id);
+ //_logger.Debug("GetitemById {0}", id);
+
if (item != null)
{
RegisterItem(item);
@@ -1508,7 +1518,7 @@ namespace MediaBrowser.Server.Implementations.Library
UserId = user.Id.ToString("N")
}, CancellationToken.None).Result;
-
+
return channelResult.Items;
}
@@ -1921,7 +1931,7 @@ namespace MediaBrowser.Server.Implementations.Library
private string GetContentTypeOverride(string path, bool inherit)
{
- var nameValuePair = ConfigurationManager.Configuration.ContentTypes.FirstOrDefault(i => string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase) || (inherit && _fileSystem.ContainsSubPath(i.Name, path)));
+ var nameValuePair = ConfigurationManager.Configuration.ContentTypes.FirstOrDefault(i => string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase) || (inherit && !string.IsNullOrWhiteSpace(i.Name) && _fileSystem.ContainsSubPath(i.Name, path)));
if (nameValuePair != null)
{
return nameValuePair.Value;
@@ -2802,6 +2812,11 @@ namespace MediaBrowser.Server.Implementations.Library
private void RemoveContentTypeOverrides(string path)
{
+ if (string.IsNullOrWhiteSpace(path))
+ {
+ throw new ArgumentNullException("path");
+ }
+
var removeList = new List<NameValuePair>();
foreach (var contentType in ConfigurationManager.Configuration.ContentTypes)