update DirectoryService

This commit is contained in:
Luke Pulverenti 2016-08-06 00:48:00 -04:00
parent d290a54845
commit 0706bd5237
11 changed files with 29 additions and 17 deletions

View File

@ -5,6 +5,7 @@ using MediaBrowser.Controller.Providers;
using ServiceStack;
using System.Threading;
using CommonIO;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Api
{
@ -39,12 +40,14 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IProviderManager _providerManager;
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;
_providerManager = providerManager;
_fileSystem = fileSystem;
_logger = logger;
}
/// <summary>
@ -69,7 +72,7 @@ namespace MediaBrowser.Api
private MetadataRefreshOptions GetRefreshOptions(BaseRefreshRequest request)
{
return new MetadataRefreshOptions(new DirectoryService(_fileSystem))
return new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem))
{
MetadataRefreshMode = request.MetadataRefreshMode,
ImageRefreshMode = request.ImageRefreshMode,

View File

@ -76,7 +76,7 @@ namespace MediaBrowser.Controller.Entities
{
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))
{

View File

@ -1003,7 +1003,7 @@ namespace MediaBrowser.Controller.Entities
public Task RefreshMetadata(CancellationToken cancellationToken)
{
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem)), cancellationToken);
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)), cancellationToken);
}
/// <summary>

View File

@ -82,7 +82,7 @@ namespace MediaBrowser.Controller.Entities
{
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))
{

View File

@ -278,7 +278,7 @@ namespace MediaBrowser.Controller.Entities
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>

View File

@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Entities
Name = newName;
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(FileSystem))
return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem))
{
ReplaceAllMetadata = true,
ImageRefreshMode = ImageRefreshMode.FullRefresh,

View File

@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Providers
_fileSystem = fileSystem;
}
public DirectoryService(IFileSystem fileSystem)
public DirectoryService(IFileSystem fileSystem)
: this(new NullLogger(), fileSystem)
{
}
@ -108,12 +108,20 @@ namespace MediaBrowser.Controller.Providers
return null;
}
var dict = GetFileSystemDictionary(directory, false);
try
{
var dict = GetFileSystemDictionary(directory, false);
FileSystemMetadata entry;
dict.TryGetValue(path, out entry);
FileSystemMetadata 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)

View File

@ -1,5 +1,6 @@
using System.Linq;
using CommonIO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Providers;
namespace MediaBrowser.Controller.Providers
@ -19,7 +20,7 @@ namespace MediaBrowser.Controller.Providers
public bool ForceSave { get; set; }
public MetadataRefreshOptions(IFileSystem fileSystem)
: this(new DirectoryService(fileSystem))
: this(new DirectoryService(new NullLogger(), fileSystem))
{
}

View File

@ -298,7 +298,7 @@ namespace MediaBrowser.Providers.Manager
{
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)
@ -488,7 +488,7 @@ namespace MediaBrowser.Providers.Manager
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);
AddImagePlugins(summary.Plugins, dummy, imageProviders);

View File

@ -254,7 +254,7 @@ namespace MediaBrowser.Providers.Subtitles
_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,
MetadataRefreshMode = MetadataRefreshMode.ValidationOnly

View File

@ -133,7 +133,7 @@ namespace MediaBrowser.Providers.TV
{
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);