|
|
@ -25,6 +25,7 @@ namespace NzbDrone.Core.RootFolders
|
|
|
|
private readonly IRootFolderRepository _rootFolderRepository;
|
|
|
|
private readonly IRootFolderRepository _rootFolderRepository;
|
|
|
|
private readonly IDiskProvider _diskProvider;
|
|
|
|
private readonly IDiskProvider _diskProvider;
|
|
|
|
private readonly ISeriesRepository _seriesRepository;
|
|
|
|
private readonly ISeriesRepository _seriesRepository;
|
|
|
|
|
|
|
|
private readonly IMovieRepository _movieRepository;
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
|
@ -44,12 +45,14 @@ namespace NzbDrone.Core.RootFolders
|
|
|
|
public RootFolderService(IRootFolderRepository rootFolderRepository,
|
|
|
|
public RootFolderService(IRootFolderRepository rootFolderRepository,
|
|
|
|
IDiskProvider diskProvider,
|
|
|
|
IDiskProvider diskProvider,
|
|
|
|
ISeriesRepository seriesRepository,
|
|
|
|
ISeriesRepository seriesRepository,
|
|
|
|
|
|
|
|
IMovieRepository movieRepository,
|
|
|
|
IConfigService configService,
|
|
|
|
IConfigService configService,
|
|
|
|
Logger logger)
|
|
|
|
Logger logger)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_rootFolderRepository = rootFolderRepository;
|
|
|
|
_rootFolderRepository = rootFolderRepository;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
_seriesRepository = seriesRepository;
|
|
|
|
_seriesRepository = seriesRepository;
|
|
|
|
|
|
|
|
_movieRepository = movieRepository;
|
|
|
|
_configService = configService;
|
|
|
|
_configService = configService;
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -128,6 +131,41 @@ namespace NzbDrone.Core.RootFolders
|
|
|
|
_rootFolderRepository.Delete(id);
|
|
|
|
_rootFolderRepository.Delete(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private List<UnmappedFolder> GetUnmappedFolders(string path)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// _logger.Debug("Generating list of unmapped folders");
|
|
|
|
|
|
|
|
// if (string.IsNullOrEmpty(path))
|
|
|
|
|
|
|
|
// throw new ArgumentException("Invalid path provided", "path");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var results = new List<UnmappedFolder>();
|
|
|
|
|
|
|
|
// var series = _seriesRepository.All().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (!_diskProvider.FolderExists(path))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// _logger.Debug("Path supplied does not exist: {0}", path);
|
|
|
|
|
|
|
|
// return results;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var seriesFolders = _diskProvider.GetDirectories(path).ToList();
|
|
|
|
|
|
|
|
// var unmappedFolders = seriesFolders.Except(series.Select(s => s.Path), PathEqualityComparer.Instance).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// foreach (string unmappedFolder in unmappedFolders)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// var di = new DirectoryInfo(unmappedFolder.Normalize());
|
|
|
|
|
|
|
|
// if (!di.Attributes.HasFlag(FileAttributes.System) && !di.Attributes.HasFlag(FileAttributes.Hidden))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// results.Add(new UnmappedFolder { Name = di.Name, Path = di.FullName });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var setToRemove = SpecialFolders;
|
|
|
|
|
|
|
|
// results.RemoveAll(x => setToRemove.Contains(new DirectoryInfo(x.Path.ToLowerInvariant()).Name));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// _logger.Debug("{0} unmapped folders detected.", results.Count);
|
|
|
|
|
|
|
|
// return results;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
private List<UnmappedFolder> GetUnmappedFolders(string path)
|
|
|
|
private List<UnmappedFolder> GetUnmappedFolders(string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Debug("Generating list of unmapped folders");
|
|
|
|
_logger.Debug("Generating list of unmapped folders");
|
|
|
@ -135,7 +173,7 @@ namespace NzbDrone.Core.RootFolders
|
|
|
|
throw new ArgumentException("Invalid path provided", "path");
|
|
|
|
throw new ArgumentException("Invalid path provided", "path");
|
|
|
|
|
|
|
|
|
|
|
|
var results = new List<UnmappedFolder>();
|
|
|
|
var results = new List<UnmappedFolder>();
|
|
|
|
var series = _seriesRepository.All().ToList();
|
|
|
|
var movies = _movieRepository.All().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
if (!_diskProvider.FolderExists(path))
|
|
|
|
if (!_diskProvider.FolderExists(path))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -143,8 +181,8 @@ namespace NzbDrone.Core.RootFolders
|
|
|
|
return results;
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var seriesFolders = _diskProvider.GetDirectories(path).ToList();
|
|
|
|
var movieFolders = _diskProvider.GetDirectories(path).ToList();
|
|
|
|
var unmappedFolders = seriesFolders.Except(series.Select(s => s.Path), PathEqualityComparer.Instance).ToList();
|
|
|
|
var unmappedFolders = movieFolders.Except(movies.Select(s => s.Path), PathEqualityComparer.Instance).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string unmappedFolder in unmappedFolders)
|
|
|
|
foreach (string unmappedFolder in unmappedFolders)
|
|
|
|
{
|
|
|
|
{
|
|
|
|