update playlist

This commit is contained in:
Luke Pulverenti 2016-05-19 15:57:30 -04:00
parent defbe7c4af
commit efe9fa8a8d
2 changed files with 35 additions and 13 deletions

View File

@ -127,9 +127,9 @@ namespace MediaBrowser.Controller.Entities
args.FileSystemDictionary = fileSystemDictionary; args.FileSystemDictionary = fileSystemDictionary;
} }
_requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations);
if (setPhysicalLocations) if (setPhysicalLocations)
{ {
_requiresRefresh = !args.PhysicalLocations.SequenceEqual(PhysicalLocations);
PhysicalLocationsList = args.PhysicalLocations.ToList(); PhysicalLocationsList = args.PhysicalLocations.ToList();
} }

View File

@ -83,7 +83,34 @@ namespace MediaBrowser.Controller.Entities
protected override IEnumerable<FileSystemMetadata> GetFileSystemChildren(IDirectoryService directoryService) protected override IEnumerable<FileSystemMetadata> 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) internal override bool IsValidFromResolver(BaseItem newItem)
@ -101,7 +128,7 @@ namespace MediaBrowser.Controller.Entities
return base.IsValidFromResolver(newItem); return base.IsValidFromResolver(newItem);
} }
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService) private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
{ {
var path = ContainingFolderPath; var path = ContainingFolderPath;
@ -135,7 +162,11 @@ namespace MediaBrowser.Controller.Entities
args.FileSystemDictionary = fileSystemDictionary; args.FileSystemDictionary = fileSystemDictionary;
} }
PhysicalLocationsList = args.PhysicalLocations.ToList(); _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations);
if (setPhysicalLocations)
{
PhysicalLocationsList = args.PhysicalLocations.ToList();
}
return args; return args;
} }
@ -153,15 +184,6 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task.</returns> /// <returns>Task.</returns>
protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) protected override Task ValidateChildrenInternal(IProgress<double> 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); return Task.FromResult(true);
} }