update DirectoryService
This commit is contained in:
parent
d290a54845
commit
0706bd5237
|
@ -5,6 +5,7 @@ using MediaBrowser.Controller.Providers;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
namespace MediaBrowser.Api
|
namespace MediaBrowser.Api
|
||||||
{
|
{
|
||||||
|
@ -39,12 +40,14 @@ namespace MediaBrowser.Api
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly IProviderManager _providerManager;
|
private readonly IProviderManager _providerManager;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public ItemRefreshService(ILibraryManager libraryManager, IProviderManager providerManager, IFileSystem fileSystem)
|
public ItemRefreshService(ILibraryManager libraryManager, IProviderManager providerManager, IFileSystem fileSystem, ILogger logger)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_providerManager = providerManager;
|
_providerManager = providerManager;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -69,7 +72,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private MetadataRefreshOptions GetRefreshOptions(BaseRefreshRequest request)
|
private MetadataRefreshOptions GetRefreshOptions(BaseRefreshRequest request)
|
||||||
{
|
{
|
||||||
return new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
return new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem))
|
||||||
{
|
{
|
||||||
MetadataRefreshMode = request.MetadataRefreshMode,
|
MetadataRefreshMode = request.MetadataRefreshMode,
|
||||||
ImageRefreshMode = request.ImageRefreshMode,
|
ImageRefreshMode = request.ImageRefreshMode,
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
var locations = PhysicalLocations.ToList();
|
var locations = PhysicalLocations.ToList();
|
||||||
|
|
||||||
var newLocations = CreateResolveArgs(new DirectoryService(BaseItem.FileSystem), false).PhysicalLocations.ToList();
|
var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations.ToList();
|
||||||
|
|
||||||
if (!locations.SequenceEqual(newLocations))
|
if (!locations.SequenceEqual(newLocations))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1003,7 +1003,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public Task RefreshMetadata(CancellationToken cancellationToken)
|
public Task RefreshMetadata(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem)), cancellationToken);
|
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)), cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
var locations = PhysicalLocations.ToList();
|
var locations = PhysicalLocations.ToList();
|
||||||
|
|
||||||
var newLocations = CreateResolveArgs(new DirectoryService(BaseItem.FileSystem), false).PhysicalLocations.ToList();
|
var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations.ToList();
|
||||||
|
|
||||||
if (!locations.SequenceEqual(newLocations))
|
if (!locations.SequenceEqual(newLocations))
|
||||||
{
|
{
|
||||||
|
|
|
@ -278,7 +278,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public Task ValidateChildren(IProgress<double> progress, CancellationToken cancellationToken)
|
public Task ValidateChildren(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return ValidateChildren(progress, cancellationToken, new MetadataRefreshOptions(new DirectoryService(FileSystem)));
|
return ValidateChildren(progress, cancellationToken, new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
Name = newName;
|
Name = newName;
|
||||||
|
|
||||||
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem))
|
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem))
|
||||||
{
|
{
|
||||||
ReplaceAllMetadata = true,
|
ReplaceAllMetadata = true,
|
||||||
ImageRefreshMode = ImageRefreshMode.FullRefresh,
|
ImageRefreshMode = ImageRefreshMode.FullRefresh,
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DirectoryService(IFileSystem fileSystem)
|
public DirectoryService(IFileSystem fileSystem)
|
||||||
: this(new NullLogger(), fileSystem)
|
: this(new NullLogger(), fileSystem)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -108,12 +108,20 @@ namespace MediaBrowser.Controller.Providers
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dict = GetFileSystemDictionary(directory, false);
|
try
|
||||||
|
{
|
||||||
|
var dict = GetFileSystemDictionary(directory, false);
|
||||||
|
|
||||||
FileSystemMetadata entry;
|
FileSystemMetadata entry;
|
||||||
dict.TryGetValue(path, out entry);
|
dict.TryGetValue(path, out entry);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error in GetFileSystemDictionary. Directory: :{0}. Original path: {1}", ex, directory, path);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<FileSystemMetadata> GetDirectories(string path)
|
public IEnumerable<FileSystemMetadata> GetDirectories(string path)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Controller.Providers
|
||||||
|
@ -19,7 +20,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
public bool ForceSave { get; set; }
|
public bool ForceSave { get; set; }
|
||||||
|
|
||||||
public MetadataRefreshOptions(IFileSystem fileSystem)
|
public MetadataRefreshOptions(IFileSystem fileSystem)
|
||||||
: this(new DirectoryService(fileSystem))
|
: this(new DirectoryService(new NullLogger(), fileSystem))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
var options = GetMetadataOptions(item);
|
var options = GetMetadataOptions(item);
|
||||||
|
|
||||||
return GetImageProviders(item, options, new ImageRefreshOptions(new DirectoryService(_fileSystem)), includeDisabled).OfType<IRemoteImageProvider>();
|
return GetImageProviders(item, options, new ImageRefreshOptions(new DirectoryService(_logger, _fileSystem)), includeDisabled).OfType<IRemoteImageProvider>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanRefresh(IMetadataProvider provider, IHasMetadata item, MetadataOptions options, bool includeDisabled, bool checkIsOwnedItem)
|
private bool CanRefresh(IMetadataProvider provider, IHasMetadata item, MetadataOptions options, bool includeDisabled, bool checkIsOwnedItem)
|
||||||
|
@ -488,7 +488,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
ItemType = typeof(T).Name
|
ItemType = typeof(T).Name
|
||||||
};
|
};
|
||||||
|
|
||||||
var imageProviders = GetImageProviders(dummy, options, new ImageRefreshOptions(new DirectoryService(_fileSystem)), true).ToList();
|
var imageProviders = GetImageProviders(dummy, options, new ImageRefreshOptions(new DirectoryService(_logger, _fileSystem)), true).ToList();
|
||||||
|
|
||||||
AddMetadataPlugins(summary.Plugins, dummy, options);
|
AddMetadataPlugins(summary.Plugins, dummy, options);
|
||||||
AddImagePlugins(summary.Plugins, dummy, imageProviders);
|
AddImagePlugins(summary.Plugins, dummy, imageProviders);
|
||||||
|
|
|
@ -254,7 +254,7 @@ namespace MediaBrowser.Providers.Subtitles
|
||||||
_monitor.ReportFileSystemChangeComplete(path, false);
|
_monitor.ReportFileSystemChangeComplete(path, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _libraryManager.GetItemById(itemId).RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
return _libraryManager.GetItemById(itemId).RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem))
|
||||||
{
|
{
|
||||||
ImageRefreshMode = ImageRefreshMode.ValidationOnly,
|
ImageRefreshMode = ImageRefreshMode.ValidationOnly,
|
||||||
MetadataRefreshMode = MetadataRefreshMode.ValidationOnly
|
MetadataRefreshMode = MetadataRefreshMode.ValidationOnly
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
{
|
{
|
||||||
foreach (var series in group)
|
foreach (var series in group)
|
||||||
{
|
{
|
||||||
var directoryService = new DirectoryService(_fileSystem);
|
var directoryService = new DirectoryService(_logger, _fileSystem);
|
||||||
|
|
||||||
await series.RefreshMetadata(new MetadataRefreshOptions(directoryService), cancellationToken).ConfigureAwait(false);
|
await series.RefreshMetadata(new MetadataRefreshOptions(directoryService), cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user