diff options
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Configuration/LibraryOptions.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/AggregateFolder.cs | 33 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/Audio.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/CollectionFolder.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 30 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/UserRootFolder.cs | 29 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/ILibraryManager.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/ItemResolveArgs.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Playlists/Playlist.cs | 6 |
12 files changed, 109 insertions, 22 deletions
diff --git a/MediaBrowser.Controller/Configuration/LibraryOptions.cs b/MediaBrowser.Controller/Configuration/LibraryOptions.cs deleted file mode 100644 index 1a824c08b..000000000 --- a/MediaBrowser.Controller/Configuration/LibraryOptions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.Configuration -{ - public class LibraryOptions - { - public bool EnableAudioArchiveFiles { get; set; } - public bool EnableVideoArchiveFiles { get; set; } - } -} diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 7b4231010..4aa99ae87 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -67,6 +67,31 @@ namespace MediaBrowser.Controller.Entities return CreateResolveArgs(directoryService, true).FileSystemChildren; } + private List<Guid> _childrenIds = null; + private readonly object _childIdsLock = new object(); + protected override IEnumerable<BaseItem> LoadChildren() + { + lock (_childIdsLock) + { + if (_childrenIds == null || _childrenIds.Count == 0) + { + var list = base.LoadChildren().ToList(); + _childrenIds = list.Select(i => i.Id).ToList(); + return list; + } + + return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList(); + } + } + + private void ResetCachedChildren() + { + lock (_childIdsLock) + { + _childrenIds = null; + } + } + private bool _requiresRefresh; public override bool RequiresRefresh() { @@ -89,6 +114,8 @@ namespace MediaBrowser.Controller.Entities public override bool BeforeMetadataRefresh() { + ResetCachedChildren(); + var changed = base.BeforeMetadataRefresh() || _requiresRefresh; _requiresRefresh = false; return changed; @@ -96,9 +123,11 @@ namespace MediaBrowser.Controller.Entities private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations) { + ResetCachedChildren(); + var path = ContainingFolderPath; - var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths , directoryService) + var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService) { FileInfo = FileSystem.GetDirectoryInfo(path), Path = path, @@ -135,7 +164,7 @@ namespace MediaBrowser.Controller.Entities return args; } - + /// <summary> /// Adds the virtual child. /// </summary> diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 6326bbd4f..1af55a389 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -5,9 +5,11 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Runtime.Serialization; using System.Threading; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Channels; namespace MediaBrowser.Controller.Entities.Audio @@ -266,6 +268,11 @@ namespace MediaBrowser.Controller.Entities.Audio Size = i.Size }; + if (info.Protocol == MediaProtocol.File) + { + info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); + } + if (string.IsNullOrEmpty(info.Container)) { if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 289cb7a2e..b81f021da 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -10,6 +10,7 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Serialization; using MoreLinq; diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index bf04c643c..23055690c 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -273,7 +273,7 @@ namespace MediaBrowser.Controller.Entities /// </summary> protected virtual IEnumerable<BaseItem> LoadChildren() { - //Logger.Debug("Loading children from {0} {1}", Id, Path); + //Logger.Debug("Loading children from {0} {1} {2}", GetType().Name, Id, Path); //just load our children from the repo - the library will be validated and maintained in other processes return GetCachedChildren(); } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index ba50a1e0d..742ade200 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -62,11 +62,18 @@ namespace MediaBrowser.Controller.Entities.Movies return UnratedItem.Movie; } - protected override IEnumerable<BaseItem> LoadChildren() + protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService) { - var first = LinkedChildren.FirstOrDefault(); + if (IsLegacyBoxSet) + { + return base.LoadChildren(); + } + return new List<BaseItem>(); + } - if (first != null && first.Type == LinkedChildType.Shortcut) + protected override IEnumerable<BaseItem> LoadChildren() + { + if (IsLegacyBoxSet) { return base.LoadChildren(); } @@ -89,7 +96,22 @@ namespace MediaBrowser.Controller.Entities.Movies { get { - return true; + if (IsLegacyBoxSet) + { + return true; + } + + return false; + } + } + + [IgnoreDataMember] + private bool IsLegacyBoxSet + { + get + { + // TODO + return false; } } diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index 4549d0d1d..a62c67c4f 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -16,6 +16,31 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class UserRootFolder : Folder { + private List<Guid> _childrenIds = null; + private readonly object _childIdsLock = new object(); + //protected override IEnumerable<BaseItem> LoadChildren() + //{ + // lock (_childIdsLock) + // { + // if (_childrenIds == null) + // { + // var list = base.LoadChildren().ToList(); + // _childrenIds = list.Select(i => i.Id).ToList(); + // return list; + // } + + // return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList(); + // } + //} + + private void ResetCachedChildren() + { + lock (_childIdsLock) + { + _childrenIds = null; + } + } + protected override async Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query) { if (query.Recursive) @@ -69,6 +94,8 @@ namespace MediaBrowser.Controller.Entities public override bool BeforeMetadataRefresh() { + ResetCachedChildren(); + var hasChanges = base.BeforeMetadataRefresh(); if (string.Equals("default", Name, StringComparison.OrdinalIgnoreCase)) @@ -82,6 +109,8 @@ namespace MediaBrowser.Controller.Entities protected override async Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { + ResetCachedChildren(); + await base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService) .ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 830747d3c..8809f155c 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -12,6 +12,7 @@ using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; using CommonIO; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Channels; namespace MediaBrowser.Controller.Entities @@ -611,6 +612,11 @@ namespace MediaBrowser.Controller.Entities SupportsDirectStream = i.VideoType == VideoType.VideoFile }; + if (info.Protocol == MediaProtocol.File) + { + info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); + } + if (i.IsShortcut) { info.Path = i.ShortcutPath; diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index edbacb5e7..0862e3eaf 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; namespace MediaBrowser.Controller.Library diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 56ec0a213..ec0ac325b 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Controller.Library { diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index e621eafde..0462117cb 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -98,7 +98,6 @@ <Compile Include="Collections\CollectionCreationOptions.cs" /> <Compile Include="Collections\CollectionEvents.cs" /> <Compile Include="Collections\ICollectionManager.cs" /> - <Compile Include="Configuration\LibraryOptions.cs" /> <Compile Include="Connect\ConnectSupporterSummary.cs" /> <Compile Include="Connect\IConnectManager.cs" /> <Compile Include="Connect\UserLinkResult.cs" /> diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 3e706f1fa..654b97d7d 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Threading.Tasks; +using MediaBrowser.Controller.Providers; namespace MediaBrowser.Controller.Playlists { @@ -69,6 +70,11 @@ namespace MediaBrowser.Controller.Playlists return GetPlayableItems(user).Result; } + protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService) + { + return new List<BaseItem>(); + } + public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query) { var items = GetPlayableItems(user).Result; |
