New: Ensure all unmapped folders are fetched when importing from a root folder

Closes #3751
pull/3819/head
Mark McDowall 4 years ago
parent b642c3acfd
commit 11cdf13148

@ -102,24 +102,30 @@ class ImportSeries extends Component {
onScroll={this.onScroll}
>
{
rootFoldersFetching && !rootFoldersPopulated &&
<LoadingIndicator />
rootFoldersFetching ? <LoadingIndicator /> : null
}
{
!rootFoldersFetching && !!rootFoldersError &&
<div>Unable to load root folders</div>
!rootFoldersFetching && !!rootFoldersError ?
<div>Unable to load root folders</div> :
null
}
{
!rootFoldersError && rootFoldersPopulated && !unmappedFolders.length &&
!rootFoldersError &&
!rootFoldersFetching &&
!unmappedFolders.length ?
<div>
All series in {path} have been imported
</div>
</div> :
null
}
{
!rootFoldersError && rootFoldersPopulated && !!unmappedFolders.length && scroller &&
!rootFoldersError &&
!rootFoldersFetching &&
!!unmappedFolders.length &&
scroller ?
<ImportSeriesTableConnector
rootFolderId={rootFolderId}
unmappedFolders={unmappedFolders}
@ -131,18 +137,22 @@ class ImportSeries extends Component {
onSelectAllChange={this.onSelectAllChange}
onSelectedChange={this.onSelectedChange}
onRemoveSelectedStateItem={this.onRemoveSelectedStateItem}
/>
/> :
null
}
</PageContentBody>
{
!rootFoldersError && rootFoldersPopulated && !!unmappedFolders.length &&
!rootFoldersError &&
!rootFoldersFetching &&
!!unmappedFolders.length ?
<ImportSeriesFooterConnector
selectedIds={this.getSelectedIds()}
showLanguageProfile={showLanguageProfile}
onInputChange={this.onInputChange}
onImportPress={this.onImportPress}
/>
/> :
null
}
</PageContent>
);

@ -76,6 +76,7 @@ class ImportSeriesConnector extends Component {
componentDidMount() {
const {
rootFolderId,
qualityProfiles,
languageProfiles,
defaultQualityProfileId,
@ -84,9 +85,7 @@ class ImportSeriesConnector extends Component {
dispatchSetAddSeriesDefault
} = this.props;
if (!this.props.rootFoldersPopulated) {
dispatchFetchRootFolders();
}
dispatchFetchRootFolders({ id: rootFolderId, timeout: false });
let setDefaults = false;
const setDefaultPayload = {};
@ -154,6 +153,8 @@ const routeMatchShape = createRouteMatchShape({
ImportSeriesConnector.propTypes = {
match: routeMatchShape.isRequired,
rootFolderId: PropTypes.number.isRequired,
rootFoldersFetching: PropTypes.bool.isRequired,
rootFoldersPopulated: PropTypes.bool.isRequired,
qualityProfiles: PropTypes.arrayOf(PropTypes.object).isRequired,
languageProfiles: PropTypes.arrayOf(PropTypes.object).isRequired,

@ -43,7 +43,7 @@ namespace NzbDrone.Api.RootFolders
private RootFolderResource GetRootFolder(int id)
{
return _rootFolderService.Get(id).ToResource();
return _rootFolderService.Get(id, true).ToResource();
}
private int CreateRootFolder(RootFolderResource rootFolderResource)

@ -2,7 +2,6 @@ using System.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using NLog;
using NzbDrone.Common;
@ -18,7 +17,7 @@ namespace NzbDrone.Core.RootFolders
List<RootFolder> AllWithUnmappedFolders();
RootFolder Add(RootFolder rootDir);
void Remove(int id);
RootFolder Get(int id);
RootFolder Get(int id, bool timeout);
string GetBestRootFolderPath(string path);
}
@ -71,7 +70,7 @@ namespace NzbDrone.Core.RootFolders
{
if (folder.Path.IsPathValid())
{
GetDetails(folder);
GetDetails(folder, true);
}
}
//We don't want an exception to prevent the root folders from loading in the UI, so they can still be deleted
@ -111,7 +110,7 @@ namespace NzbDrone.Core.RootFolders
_rootFolderRepository.Insert(rootFolder);
GetDetails(rootFolder);
GetDetails(rootFolder, true);
return rootFolder;
}
@ -155,10 +154,10 @@ namespace NzbDrone.Core.RootFolders
return results.OrderBy(u => u.Name, StringComparer.InvariantCultureIgnoreCase).ToList();
}
public RootFolder Get(int id)
public RootFolder Get(int id, bool timeout)
{
var rootFolder = _rootFolderRepository.Get(id);
GetDetails(rootFolder);
GetDetails(rootFolder, timeout);
return rootFolder;
}
@ -177,7 +176,7 @@ namespace NzbDrone.Core.RootFolders
return possibleRootFolder.Path;
}
private void GetDetails(RootFolder rootFolder)
private void GetDetails(RootFolder rootFolder, bool timeout)
{
Task.Run(() =>
{
@ -188,7 +187,7 @@ namespace NzbDrone.Core.RootFolders
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path);
}
}).Wait(5000);
}).Wait(timeout ? 5000 : -1);
}
}
}

@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Threading;
using FluentValidation;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.SignalR;
using Sonarr.Http;
using Sonarr.Http.Extensions;
namespace Sonarr.Api.V3.RootFolders
{
@ -42,7 +44,9 @@ namespace Sonarr.Api.V3.RootFolders
private RootFolderResource GetRootFolder(int id)
{
return _rootFolderService.Get(id).ToResource();
var timeout = Request.GetBooleanQueryParameter("timeout", true);
return _rootFolderService.Get(id, timeout).ToResource();
}
private int CreateRootFolder(RootFolderResource rootFolderResource)

Loading…
Cancel
Save