From efe9fa8a8d7806cee7478a16152d7987c4b51ef5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 19 May 2016 15:57:30 -0400 Subject: [PATCH] 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); }