mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
New: Health check for import lists with missing root folders
New: Show missing root folder path in edit for Import List Closes #5908 (cherry picked from commit ae196af2ad368d49fde2358f0987ed7650c7f29c)
This commit is contained in:
parent
33cd9f555e
commit
2fd030bd5c
@ -10,13 +10,16 @@ const ADD_NEW_KEY = 'addNew';
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.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,
|
||||
freeSpace: rootFolder.freeSpace
|
||||
freeSpace: rootFolder.freeSpace,
|
||||
isMissing: false
|
||||
};
|
||||
});
|
||||
|
||||
@ -24,7 +27,8 @@ function createMapStateToProps() {
|
||||
values.unshift({
|
||||
key: 'noChange',
|
||||
value: 'No Change',
|
||||
isDisabled: true
|
||||
isDisabled: true,
|
||||
isMissing: false
|
||||
});
|
||||
}
|
||||
|
||||
@ -37,6 +41,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: 'Add a new path'
|
||||
|
@ -29,3 +29,9 @@
|
||||
color: $darkGray;
|
||||
font-size: $smallFontSize;
|
||||
}
|
||||
|
||||
.isMissing {
|
||||
margin-left: 15px;
|
||||
color: $dangerColor;
|
||||
font-size: $smallFontSize;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ function RootFolderSelectInputOption(props) {
|
||||
id,
|
||||
value,
|
||||
freeSpace,
|
||||
isMissing,
|
||||
movieFolder,
|
||||
isMobile,
|
||||
isWindows,
|
||||
@ -43,11 +44,20 @@ function RootFolderSelectInputOption(props) {
|
||||
</div>
|
||||
|
||||
{
|
||||
freeSpace != null &&
|
||||
freeSpace == null ?
|
||||
null :
|
||||
<div className={styles.freeSpace}>
|
||||
{formatBytes(freeSpace)} Free
|
||||
</div>
|
||||
}
|
||||
|
||||
{
|
||||
isMissing ?
|
||||
<div className={styles.isMissing}>
|
||||
Missing
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
</div>
|
||||
</EnhancedSelectInputOption>
|
||||
);
|
||||
@ -58,6 +68,7 @@ RootFolderSelectInputOption.propTypes = {
|
||||
value: PropTypes.string.isRequired,
|
||||
freeSpace: PropTypes.number,
|
||||
movieFolder: PropTypes.string,
|
||||
isMissing: PropTypes.boolean,
|
||||
isMobile: PropTypes.bool.isRequired,
|
||||
isWindows: PropTypes.bool
|
||||
};
|
||||
|
@ -164,6 +164,7 @@ function EditImportListModalContent(props) {
|
||||
type={inputTypes.ROOT_FOLDER_SELECT}
|
||||
name="rootFolderPath"
|
||||
{...rootFolderPath}
|
||||
includeMissingValue={true}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.ImportLists;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
[CheckOn(typeof(SeriesDeletedEvent))]
|
||||
[CheckOn(typeof(SeriesMovedEvent))]
|
||||
[CheckOn(typeof(EpisodeImportedEvent), CheckOnCondition.FailedOnly)]
|
||||
[CheckOn(typeof(EpisodeImportFailedEvent), CheckOnCondition.SuccessfulOnly)]
|
||||
public class ImportListRootFolderCheck : HealthCheckBase
|
||||
{
|
||||
private readonly IImportListFactory _importListFactory;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
|
||||
public ImportListRootFolderCheck(IImportListFactory importListFactory, IDiskProvider diskProvider)
|
||||
{
|
||||
_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, $"Missing root folder for import list(s): {FormatRootFolder(missingRootFolder.Key, missingRootFolder.Value)}", "#import_list_missing_root_folder");
|
||||
}
|
||||
|
||||
var message = string.Format("Multiple root folders are missing for import lists: {0}", 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))})";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user