Don't display mapped movies in import list

When importing existing movies, don't list those which already exist in the collection.
Tim Turner 8 years ago
parent 3ab0b17379
commit e185ba0191

@ -38,8 +38,8 @@ namespace NzbDrone.Api.RootFolders
Id = resource.Id, Id = resource.Id,
Path = resource.Path, Path = resource.Path,
//FreeSpace FreeSpace = resource.FreeSpace,
//UnmappedFolders UnmappedFolders = resource.UnmappedFolders
}; };
} }

@ -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)
{ {

@ -55,7 +55,7 @@ module.exports = Marionette.Layout.extend({
_folderSelected : function(options) { _folderSelected : function(options) {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
this.ui.$existing.show(); //this.ui.$existing.show();
this.workspace.show(new ExistingMoviesCollectionView({ model : options.model })); this.workspace.show(new ExistingMoviesCollectionView({ model : options.model }));
}, },
@ -70,7 +70,7 @@ module.exports = Marionette.Layout.extend({
}, },
_addFromList : function() { _addFromList : function() {
this.ui.$existing.hide(); //this.ui.$existing.hide();
this.workspace.show(new AddFromListView()); this.workspace.show(new AddFromListView());
} }
}); });

Loading…
Cancel
Save