add more methods to IFileSystem

This commit is contained in:
Luke Pulverenti
2015-09-13 19:07:54 -04:00
parent 6cb184fcf8
commit 8cf45a3e4a
64 changed files with 296 additions and 149 deletions

View File

@@ -548,7 +548,7 @@ namespace MediaBrowser.Server.Implementations.Library
public BaseItem ResolvePath(FileSystemInfo fileInfo,
Folder parent = null)
{
return ResolvePath(fileInfo, new DirectoryService(_logger), parent);
return ResolvePath(fileInfo, new DirectoryService(_logger, _fileSystem), parent);
}
private BaseItem ResolvePath(FileSystemInfo fileInfo, IDirectoryService directoryService, Folder parent = null, string collectionType = null)
@@ -1009,7 +1009,7 @@ namespace MediaBrowser.Server.Implementations.Library
// Ensure the location is available.
_fileSystem.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath);
return new PeopleValidator(this, _logger, ConfigurationManager).ValidatePeople(cancellationToken, progress);
return new PeopleValidator(this, _logger, ConfigurationManager, _fileSystem).ValidatePeople(cancellationToken, progress);
}
/// <summary>
@@ -1064,7 +1064,7 @@ namespace MediaBrowser.Server.Implementations.Library
progress.Report(.5);
// Start by just validating the children of the root, but go no further
await RootFolder.ValidateChildren(new Progress<double>(), cancellationToken, new MetadataRefreshOptions(), recursive: false);
await RootFolder.ValidateChildren(new Progress<double>(), cancellationToken, new MetadataRefreshOptions(_fileSystem), recursive: false);
progress.Report(1);
@@ -1072,7 +1072,7 @@ namespace MediaBrowser.Server.Implementations.Library
await userRoot.RefreshMetadata(cancellationToken).ConfigureAwait(false);
await userRoot.ValidateChildren(new Progress<double>(), cancellationToken, new MetadataRefreshOptions(), recursive: false).ConfigureAwait(false);
await userRoot.ValidateChildren(new Progress<double>(), cancellationToken, new MetadataRefreshOptions(_fileSystem), recursive: false).ConfigureAwait(false);
progress.Report(2);
var innerProgress = new ActionableProgress<double>();
@@ -1080,7 +1080,7 @@ namespace MediaBrowser.Server.Implementations.Library
innerProgress.RegisterAction(pct => progress.Report(2 + pct * .73));
// Now validate the entire media library
await RootFolder.ValidateChildren(innerProgress, cancellationToken, new MetadataRefreshOptions(), recursive: true).ConfigureAwait(false);
await RootFolder.ValidateChildren(innerProgress, cancellationToken, new MetadataRefreshOptions(_fileSystem), recursive: true).ConfigureAwait(false);
progress.Report(75);
@@ -1702,7 +1702,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (refresh)
{
await item.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None).ConfigureAwait(false);
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions(_fileSystem)
{
// Not sure why this is necessary but need to figure it out
// View images are not getting utilized without this
@@ -1790,7 +1790,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (refresh)
{
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions(_fileSystem)
{
// Need to force save to increment DateLastSaved
ForceSave = true
@@ -1860,7 +1860,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (refresh)
{
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions(_fileSystem)
{
// Need to force save to increment DateLastSaved
ForceSave = true

View File

@@ -15,6 +15,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
namespace MediaBrowser.Server.Implementations.Library
{
@@ -24,17 +25,19 @@ namespace MediaBrowser.Server.Implementations.Library
private readonly IUserManager _userManager;
private readonly ILibraryManager _libraryManager;
private readonly IJsonSerializer _jsonSerializer;
private readonly IFileSystem _fileSystem;
private IMediaSourceProvider[] _providers;
private readonly ILogger _logger;
public MediaSourceManager(IItemRepository itemRepo, IUserManager userManager, ILibraryManager libraryManager, ILogger logger, IJsonSerializer jsonSerializer)
public MediaSourceManager(IItemRepository itemRepo, IUserManager userManager, ILibraryManager libraryManager, ILogger logger, IJsonSerializer jsonSerializer, IFileSystem fileSystem)
{
_itemRepo = itemRepo;
_userManager = userManager;
_libraryManager = libraryManager;
_logger = logger;
_jsonSerializer = jsonSerializer;
_fileSystem = fileSystem;
}
public void AddParts(IEnumerable<IMediaSourceProvider> providers)

View File

@@ -454,7 +454,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task.</returns>
public Task RefreshUsersMetadata(CancellationToken cancellationToken)
{
var tasks = Users.Select(user => user.RefreshMetadata(new MetadataRefreshOptions(), cancellationToken)).ToList();
var tasks = Users.Select(user => user.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken)).ToList();
return Task.WhenAll(tasks);
}

View File

@@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
@@ -29,17 +30,19 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
private readonly ILogger _logger;
private readonly IServerConfigurationManager _config;
private readonly IFileSystem _fileSystem;
/// <summary>
/// Initializes a new instance of the <see cref="PeopleValidator" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
public PeopleValidator(ILibraryManager libraryManager, ILogger logger, IServerConfigurationManager config)
public PeopleValidator(ILibraryManager libraryManager, ILogger logger, IServerConfigurationManager config, IFileSystem fileSystem)
{
_libraryManager = libraryManager;
_logger = logger;
_config = config;
_fileSystem = fileSystem;
}
private bool DownloadMetadata(PersonInfo i, PeopleMetadataOptions options)
@@ -121,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
validIds.Add(item.Id);
var options = new MetadataRefreshOptions
var options = new MetadataRefreshOptions(_fileSystem)
{
MetadataRefreshMode = person.Value ? MetadataRefreshMode.Default : MetadataRefreshMode.ValidationOnly,
ImageRefreshMode = person.Value ? ImageRefreshMode.Default : ImageRefreshMode.ValidationOnly