From defbe7c4afc7a4a8a021797efa2316c377bf0063 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 19 May 2016 15:06:58 -0400 Subject: [PATCH 1/2] add ignore attribute --- MediaBrowser.Controller/Entities/Audio/MusicArtist.cs | 1 + MediaBrowser.Controller/Entities/CollectionFolder.cs | 1 + MediaBrowser.Controller/Entities/Folder.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index df46e42086..02dad93cbe 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -72,6 +72,7 @@ namespace MediaBrowser.Controller.Entities.Audio return LibraryManager.GetItemList(query); } + [IgnoreDataMember] protected override IEnumerable ActualChildren { get diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 5e0cf6e88b..84fd6df5ee 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -188,6 +188,7 @@ namespace MediaBrowser.Controller.Entities /// Our children are actually just references to the ones in the physical root... /// /// The actual children. + [IgnoreDataMember] protected override IEnumerable ActualChildren { get { return GetActualChildren(); } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 57b218b4d2..3e717862a9 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -285,6 +285,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the actual children. /// /// The actual children. + [IgnoreDataMember] protected virtual IEnumerable ActualChildren { get From efe9fa8a8d7806cee7478a16152d7987c4b51ef5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 19 May 2016 15:57:30 -0400 Subject: [PATCH 2/2] update playlist --- .../Entities/AggregateFolder.cs | 2 +- .../Entities/CollectionFolder.cs | 46 ++++++++++++++----- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 3efe46bad8..588a65e98d 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -127,9 +127,9 @@ namespace MediaBrowser.Controller.Entities args.FileSystemDictionary = fileSystemDictionary; } + _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); if (setPhysicalLocations) { - _requiresRefresh = !args.PhysicalLocations.SequenceEqual(PhysicalLocations); PhysicalLocationsList = args.PhysicalLocations.ToList(); } diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 84fd6df5ee..b81276ae71 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -83,7 +83,34 @@ namespace MediaBrowser.Controller.Entities protected override IEnumerable GetFileSystemChildren(IDirectoryService directoryService) { - return CreateResolveArgs(directoryService).FileSystemChildren; + return CreateResolveArgs(directoryService, true).FileSystemChildren; + } + + private bool _requiresRefresh; + public override bool RequiresRefresh() + { + var changed = base.RequiresRefresh() || _requiresRefresh; + + if (!changed) + { + var locations = PhysicalLocations.ToList(); + + var newLocations = CreateResolveArgs(new DirectoryService(BaseItem.FileSystem), false).PhysicalLocations.ToList(); + + if (!locations.SequenceEqual(newLocations)) + { + changed = true; + } + } + + return changed; + } + + public override bool BeforeMetadataRefresh() + { + var changed = base.BeforeMetadataRefresh() || _requiresRefresh; + _requiresRefresh = false; + return changed; } internal override bool IsValidFromResolver(BaseItem newItem) @@ -101,7 +128,7 @@ namespace MediaBrowser.Controller.Entities return base.IsValidFromResolver(newItem); } - private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService) + private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations) { var path = ContainingFolderPath; @@ -135,7 +162,11 @@ namespace MediaBrowser.Controller.Entities args.FileSystemDictionary = fileSystemDictionary; } - PhysicalLocationsList = args.PhysicalLocations.ToList(); + _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); + if (setPhysicalLocations) + { + PhysicalLocationsList = args.PhysicalLocations.ToList(); + } return args; } @@ -153,15 +184,6 @@ namespace MediaBrowser.Controller.Entities /// Task. protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { - var list = PhysicalLocationsList.ToList(); - - CreateResolveArgs(directoryService); - - if (!list.SequenceEqual(PhysicalLocationsList)) - { - return UpdateToRepository(ItemUpdateType.MetadataImport, cancellationToken); - } - return Task.FromResult(true); }