mirror of
https://github.com/fergalmoran/Readarr.git
synced 2025-12-22 09:29:59 +00:00
New: Health check for import lists with missing root folders
New: Show missing root folder path in edit for Import List (cherry picked from commit ae196af2ad368d49fde2358f0987ed7650c7f29c) Closes #821
This commit is contained in:
@@ -9,14 +9,17 @@ const ADD_NEW_KEY = 'addNew';
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.settings.rootFolders,
|
||||
(state, { value }) => value,
|
||||
(state, { includeMissingValue }) => includeMissingValue,
|
||||
(state, { includeNoChange }) => includeNoChange,
|
||||
(rootFolders, includeNoChange) => {
|
||||
(rootFolders, value, includeMissingValue, includeNoChange) => {
|
||||
const values = rootFolders.items.map((rootFolder) => {
|
||||
return {
|
||||
key: rootFolder.path,
|
||||
value: rootFolder.path,
|
||||
name: rootFolder.name,
|
||||
freeSpace: rootFolder.freeSpace
|
||||
freeSpace: rootFolder.freeSpace,
|
||||
isMissing: false
|
||||
};
|
||||
});
|
||||
|
||||
@@ -25,7 +28,8 @@ function createMapStateToProps() {
|
||||
key: 'noChange',
|
||||
value: '',
|
||||
name: 'No Change',
|
||||
isDisabled: true
|
||||
isDisabled: true,
|
||||
isMissing: false
|
||||
});
|
||||
}
|
||||
|
||||
@@ -39,6 +43,15 @@ function createMapStateToProps() {
|
||||
});
|
||||
}
|
||||
|
||||
if (includeMissingValue && !values.find((v) => v.key === value)) {
|
||||
values.push({
|
||||
key: value,
|
||||
value,
|
||||
isMissing: true,
|
||||
isDisabled: true
|
||||
});
|
||||
}
|
||||
|
||||
values.push({
|
||||
key: ADD_NEW_KEY,
|
||||
value: '',
|
||||
|
||||
@@ -18,3 +18,9 @@
|
||||
color: var(--darkGray);
|
||||
font-size: $smallFontSize;
|
||||
}
|
||||
|
||||
.isMissing {
|
||||
margin-left: 15px;
|
||||
color: var(--dangerColor);
|
||||
font-size: $smallFontSize;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ function RootFolderSelectInputOption(props) {
|
||||
value,
|
||||
name,
|
||||
freeSpace,
|
||||
isMissing,
|
||||
isMobile,
|
||||
...otherProps
|
||||
} = props;
|
||||
@@ -29,11 +30,20 @@ function RootFolderSelectInputOption(props) {
|
||||
<div>{text}</div>
|
||||
|
||||
{
|
||||
freeSpace != null &&
|
||||
freeSpace == null ?
|
||||
null :
|
||||
<div className={styles.freeSpace}>
|
||||
{formatBytes(freeSpace)} Free
|
||||
</div>
|
||||
}
|
||||
|
||||
{
|
||||
isMissing ?
|
||||
<div className={styles.isMissing}>
|
||||
Missing
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
</div>
|
||||
</EnhancedSelectInputOption>
|
||||
);
|
||||
@@ -43,6 +53,7 @@ RootFolderSelectInputOption.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
value: PropTypes.string.isRequired,
|
||||
freeSpace: PropTypes.number,
|
||||
isMissing: PropTypes.bool,
|
||||
isMobile: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
|
||||
@@ -222,6 +222,7 @@ function EditImportListModalContent(props) {
|
||||
name="rootFolderPath"
|
||||
helpText={translate('RootFolderPathHelpText')}
|
||||
{...rootFolderPath}
|
||||
includeMissingValue={true}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Books.Events;
|
||||
using NzbDrone.Core.ImportLists;
|
||||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
[CheckOn(typeof(AuthorDeletedEvent))]
|
||||
[CheckOn(typeof(AuthorMovedEvent))]
|
||||
[CheckOn(typeof(BookImportedEvent), CheckOnCondition.FailedOnly)]
|
||||
[CheckOn(typeof(TrackImportedEvent), CheckOnCondition.FailedOnly)]
|
||||
[CheckOn(typeof(TrackImportFailedEvent), CheckOnCondition.SuccessfulOnly)]
|
||||
public class ImportListRootFolderCheck : HealthCheckBase
|
||||
{
|
||||
private readonly IImportListFactory _importListFactory;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
|
||||
public ImportListRootFolderCheck(IImportListFactory importListFactory, IDiskProvider diskProvider, ILocalizationService localizationService)
|
||||
: base(localizationService)
|
||||
{
|
||||
_importListFactory = importListFactory;
|
||||
_diskProvider = diskProvider;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
var importLists = _importListFactory.All();
|
||||
var missingRootFolders = new Dictionary<string, List<ImportListDefinition>>();
|
||||
|
||||
foreach (var importList in importLists)
|
||||
{
|
||||
var rootFolderPath = importList.RootFolderPath;
|
||||
|
||||
if (missingRootFolders.ContainsKey(rootFolderPath))
|
||||
{
|
||||
missingRootFolders[rootFolderPath].Add(importList);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderExists(rootFolderPath))
|
||||
{
|
||||
missingRootFolders.Add(rootFolderPath, new List<ImportListDefinition> { importList });
|
||||
}
|
||||
}
|
||||
|
||||
if (missingRootFolders.Any())
|
||||
{
|
||||
if (missingRootFolders.Count == 1)
|
||||
{
|
||||
var missingRootFolder = missingRootFolders.First();
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("ImportListMissingRoot"), FormatRootFolder(missingRootFolder.Key, missingRootFolder.Value)), "#import-list-missing-root-folder");
|
||||
}
|
||||
|
||||
var message = string.Format(_localizationService.GetLocalizedString("ImportListMultipleMissingRoots"), string.Join(" | ", missingRootFolders.Select(m => FormatRootFolder(m.Key, m.Value))));
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Error, message, "#import_list_missing_root_folder");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
private string FormatRootFolder(string rootFolderPath, List<ImportListDefinition> importLists)
|
||||
{
|
||||
return $"{rootFolderPath} ({string.Join(", ", importLists.Select(l => l.Name))})";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,6 +348,8 @@
|
||||
"ImportFailedInterp": "Import failed: {0}",
|
||||
"ImportFailures": "Import failures",
|
||||
"ImportListExclusions": "Import List Exclusions",
|
||||
"ImportListMissingRoot": "Missing root folder for import list(s): {0}",
|
||||
"ImportListMultipleMissingRoots": "Multiple root folders are missing for import lists: {0}",
|
||||
"ImportListSettings": "General Import List Settings",
|
||||
"ImportListSpecificSettings": "Import List Specific Settings",
|
||||
"ImportListStatusCheckAllClientMessage": "All lists are unavailable due to failures",
|
||||
|
||||
Reference in New Issue
Block a user