diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 3efe46bad..588a65e98 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 84fd6df5e..b81276ae7 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); }