mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-27 11:21:43 +02:00
parent
ac407ca2c0
commit
72bc7ed6d4
@ -1,7 +1,16 @@
|
|||||||
.link {
|
.link {
|
||||||
composes: link from '~Components/Link/Link.css';
|
composes: link from '~Components/Link/Link.css';
|
||||||
|
}
|
||||||
|
|
||||||
display: block;
|
.unavailablePath {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unavailableLabel {
|
||||||
|
composes: label from '~Components/Label.css';
|
||||||
|
|
||||||
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.freeSpace,
|
.freeSpace,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import formatBytes from 'Utilities/Number/formatBytes';
|
import formatBytes from 'Utilities/Number/formatBytes';
|
||||||
import { icons } from 'Helpers/Props';
|
import { icons, kinds } from 'Helpers/Props';
|
||||||
|
import Label from 'Components/Label';
|
||||||
import IconButton from 'Components/Link/IconButton';
|
import IconButton from 'Components/Link/IconButton';
|
||||||
import Link from 'Components/Link/Link';
|
import Link from 'Components/Link/Link';
|
||||||
import TableRow from 'Components/Table/TableRow';
|
import TableRow from 'Components/Table/TableRow';
|
||||||
@ -18,20 +19,35 @@ function RootFolderRow(props) {
|
|||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const unmappedFoldersCount = unmappedFolders.length || '-';
|
const unmappedFoldersCount = unmappedFolders.length || '-';
|
||||||
|
const isUnavailable = freeSpace == null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableRowCell>
|
<TableRowCell>
|
||||||
<Link
|
{
|
||||||
className={styles.link}
|
isUnavailable ?
|
||||||
to={`/add/import/${id}`}
|
<div className={styles.unavailablePath}>
|
||||||
>
|
{path}
|
||||||
{path}
|
|
||||||
</Link>
|
<Label
|
||||||
|
className={styles.unavailableLabel}
|
||||||
|
kind={kinds.DANGER}
|
||||||
|
>
|
||||||
|
Unavailable
|
||||||
|
</Label>
|
||||||
|
</div> :
|
||||||
|
|
||||||
|
<Link
|
||||||
|
className={styles.link}
|
||||||
|
to={`/add/import/${id}`}
|
||||||
|
>
|
||||||
|
{path}
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
|
|
||||||
<TableRowCell className={styles.freeSpace}>
|
<TableRowCell className={styles.freeSpace}>
|
||||||
{formatBytes(freeSpace) || '-'}
|
{freeSpace ? formatBytes(freeSpace) : '-'}
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
|
|
||||||
<TableRowCell className={styles.unmappedFolders}>
|
<TableRowCell className={styles.unmappedFolders}>
|
||||||
@ -52,13 +68,12 @@ function RootFolderRow(props) {
|
|||||||
RootFolderRow.propTypes = {
|
RootFolderRow.propTypes = {
|
||||||
id: PropTypes.number.isRequired,
|
id: PropTypes.number.isRequired,
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
freeSpace: PropTypes.number.isRequired,
|
freeSpace: PropTypes.number,
|
||||||
unmappedFolders: PropTypes.arrayOf(PropTypes.object).isRequired,
|
unmappedFolders: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
onDeletePress: PropTypes.func.isRequired
|
onDeletePress: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
RootFolderRow.defaultProps = {
|
RootFolderRow.defaultProps = {
|
||||||
freeSpace: 0,
|
|
||||||
unmappedFolders: []
|
unmappedFolders: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ using FluentAssertions;
|
|||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
@ -2,6 +2,8 @@ using System.Linq;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
@ -67,11 +69,9 @@ namespace NzbDrone.Core.RootFolders
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (folder.Path.IsPathValid() && _diskProvider.FolderExists(folder.Path))
|
if (folder.Path.IsPathValid())
|
||||||
{
|
{
|
||||||
folder.FreeSpace = _diskProvider.GetAvailableSpace(folder.Path);
|
GetDetails(folder);
|
||||||
folder.TotalSpace = _diskProvider.GetTotalSize(folder.Path);
|
|
||||||
folder.UnmappedFolders = GetUnmappedFolders(folder.Path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//We don't want an exception to prevent the root folders from loading in the UI, so they can still be deleted
|
//We don't want an exception to prevent the root folders from loading in the UI, so they can still be deleted
|
||||||
@ -111,9 +111,7 @@ namespace NzbDrone.Core.RootFolders
|
|||||||
|
|
||||||
_rootFolderRepository.Insert(rootFolder);
|
_rootFolderRepository.Insert(rootFolder);
|
||||||
|
|
||||||
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
|
GetDetails(rootFolder);
|
||||||
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
|
|
||||||
rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path);
|
|
||||||
|
|
||||||
return rootFolder;
|
return rootFolder;
|
||||||
}
|
}
|
||||||
@ -160,9 +158,8 @@ namespace NzbDrone.Core.RootFolders
|
|||||||
public RootFolder Get(int id)
|
public RootFolder Get(int id)
|
||||||
{
|
{
|
||||||
var rootFolder = _rootFolderRepository.Get(id);
|
var rootFolder = _rootFolderRepository.Get(id);
|
||||||
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
|
GetDetails(rootFolder);
|
||||||
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
|
|
||||||
rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path);
|
|
||||||
return rootFolder;
|
return rootFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,5 +176,19 @@ namespace NzbDrone.Core.RootFolders
|
|||||||
|
|
||||||
return possibleRootFolder.Path;
|
return possibleRootFolder.Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GetDetails(RootFolder rootFolder)
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (_diskProvider.FolderExists(rootFolder.Path))
|
||||||
|
{
|
||||||
|
rootFolder.FreeSpace = _diskProvider.GetAvailableSpace(rootFolder.Path);
|
||||||
|
rootFolder.TotalSpace = _diskProvider.GetTotalSize(rootFolder.Path);
|
||||||
|
rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.Wait(5000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user