Fixed: Ensure correct series is used for Manual File Import from series details page

This commit is contained in:
Mark McDowall 2019-08-12 21:57:11 -07:00
parent 7cb5bd9c95
commit 44c91fb90c
6 changed files with 33 additions and 16 deletions

View File

@ -43,6 +43,7 @@ class InteractiveImportModalContentConnector extends Component {
componentDidMount() {
const {
downloadId,
seriesId,
folder
} = this.props;
@ -52,6 +53,7 @@ class InteractiveImportModalContentConnector extends Component {
this.props.dispatchFetchInteractiveImportItems({
downloadId,
seriesId,
folder,
filterExistingFiles
});
@ -65,11 +67,13 @@ class InteractiveImportModalContentConnector extends Component {
if (prevState.filterExistingFiles !== filterExistingFiles) {
const {
downloadId,
seriesId,
folder
} = this.props;
this.props.dispatchFetchInteractiveImportItems({
downloadId,
seriesId,
folder,
filterExistingFiles
});
@ -185,6 +189,7 @@ class InteractiveImportModalContentConnector extends Component {
InteractiveImportModalContentConnector.propTypes = {
downloadId: PropTypes.string,
seriesId: PropTypes.number,
folder: PropTypes.string,
filterExistingFiles: PropTypes.bool.isRequired,
items: PropTypes.arrayOf(PropTypes.object).isRequired,

View File

@ -23,6 +23,7 @@ import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton';
import Popover from 'Components/Tooltip/Popover';
import Tooltip from 'Components/Tooltip/Tooltip';
import EpisodeFileEditorModal from 'EpisodeFile/Editor/EpisodeFileEditorModal';
import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal';
import OrganizePreviewModalConnector from 'Organize/OrganizePreviewModalConnector';
import QualityProfileNameConnector from 'Settings/Profiles/Quality/QualityProfileNameConnector';
import SeriesPoster from 'Series/SeriesPoster';
@ -34,7 +35,6 @@ import SeriesDetailsSeasonConnector from './SeriesDetailsSeasonConnector';
import SeriesTagsConnector from './SeriesTagsConnector';
import SeriesDetailsLinks from './SeriesDetailsLinks';
import styles from './SeriesDetails.css';
import InteractiveImportModal from '../../InteractiveImport/InteractiveImportModal';
const defaultFontSize = parseInt(fonts.defaultFontSize);
const lineHeight = parseFloat(fonts.lineHeight);
@ -638,6 +638,7 @@ class SeriesDetails extends Component {
<InteractiveImportModal
isOpen={isInteractiveImportModalOpen}
seriesId={id}
folder={path}
allowSeriesChange={false}
showFilterExistingFiles={true}

View File

@ -28,7 +28,9 @@ namespace NzbDrone.Api.ManualImport
var downloadId = (string)downloadIdQuery.Value;
var filterExistingFiles = Request.GetBooleanQueryParameter("filterExistingFiles", true);
return _manualImportService.GetMediaFiles(folder, downloadId, filterExistingFiles).ToResource().Select(AddQualityWeight).ToList();
return _manualImportService.GetMediaFiles(folder, downloadId, null, filterExistingFiles)
.ToResource()
.Select(AddQualityWeight).ToList();
}
private ManualImportResource AddQualityWeight(ManualImportResource item)

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
{
public interface IManualImportService
{
List<ManualImportItem> GetMediaFiles(string path, string downloadId, bool filterExistingFiles);
List<ManualImportItem> GetMediaFiles(string path, string downloadId, int? seriesId, bool filterExistingFiles);
ManualImportItem ReprocessItem(string path, string downloadId, int seriesId);
}
@ -66,7 +66,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
_logger = logger;
}
public List<ManualImportItem> GetMediaFiles(string path, string downloadId, bool filterExistingFiles)
public List<ManualImportItem> GetMediaFiles(string path, string downloadId, int? seriesId, bool filterExistingFiles)
{
if (downloadId.IsNotNullOrWhiteSpace())
{
@ -91,7 +91,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
return new List<ManualImportItem> { ProcessFile(rootFolder, rootFolder, path, downloadId) };
}
return ProcessFolder(path, path, downloadId, filterExistingFiles);
return ProcessFolder(path, path, downloadId, seriesId, filterExistingFiles);
}
public ManualImportItem ReprocessItem(string path, string downloadId, int seriesId)
@ -102,11 +102,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
return ProcessFile(rootFolder, rootFolder, path, downloadId, series);
}
private List<ManualImportItem> ProcessFolder(string rootFolder, string baseFolder, string downloadId, bool filterExistingFiles)
private List<ManualImportItem> ProcessFolder(string rootFolder, string baseFolder, string downloadId, int? seriesId, bool filterExistingFiles)
{
DownloadClientItem downloadClientItem = null;
var directoryInfo = new DirectoryInfo(baseFolder);
var series = _parsingService.GetSeries(directoryInfo.Name);
var series = seriesId.HasValue ?
_seriesService.GetSeries(seriesId.Value) :
_parsingService.GetSeries(directoryInfo.Name);
if (downloadId.IsNotNullOrWhiteSpace())
{
@ -119,20 +122,13 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
}
}
// Try a lookup by the path if the series is still unknown, this will handle
// the case where the series folder doesn't match the series title.
if (series == null)
{
series = _seriesService.FindByPath(rootFolder);
}
if (series == null)
{
var files = _diskScanService.FilterFiles(baseFolder, _diskScanService.GetVideoFiles(baseFolder, false));
var subfolders = _diskScanService.FilterFiles(baseFolder, _diskProvider.GetDirectories(baseFolder));
var processedFiles = files.Select(file => ProcessFile(rootFolder, baseFolder, file, downloadId));
var processedFolders = subfolders.SelectMany(subfolder => ProcessFolder(rootFolder, subfolder, downloadId, filterExistingFiles));
var processedFolders = subfolders.SelectMany(subfolder => ProcessFolder(rootFolder, subfolder, downloadId, null, filterExistingFiles));
return processedFiles.Concat(processedFolders).Where(i => i != null).ToList();
}

View File

@ -27,8 +27,9 @@ namespace Sonarr.Api.V3.ManualImport
var folder = (string)Request.Query.folder;
var downloadId = (string)Request.Query.downloadId;
var filterExistingFiles = Request.GetBooleanQueryParameter("filterExistingFiles", true);
var seriesId = Request.GetNullableIntegerQueryParameter("seriesId", null);
return _manualImportService.GetMediaFiles(folder, downloadId, filterExistingFiles).ToResource().Select(AddQualityWeight).ToList();
return _manualImportService.GetMediaFiles(folder, downloadId, seriesId, filterExistingFiles).ToResource().Select(AddQualityWeight).ToList();
}
private Response ReprocessItems()

View File

@ -66,5 +66,17 @@ namespace Sonarr.Http.Extensions
return defaultValue;
}
public static int? GetNullableIntegerQueryParameter(this Request request, string parameter, int? defaultValue = null)
{
var parameterValue = request.Query[parameter];
if (parameterValue.HasValue)
{
return int.Parse(parameterValue.Value);
}
return defaultValue;
}
}
}