Fixed: Filter mapped drives when running from service

pull/6/head
Qstick 7 years ago
parent 70dc4d86dc
commit 68aaa49e9f

@ -5,6 +5,18 @@
flex-direction: column; flex-direction: column;
} }
.mappedDrivesWarning {
composes: alert from 'Components/Alert.css';
margin: 0;
margin-bottom: 20px;
}
.faqLink {
color: $alertWarningColor;
font-weight: bold;
}
.pathInput { .pathInput {
composes: pathInputWrapper from 'Components/Form/PathInput.css'; composes: pathInputWrapper from 'Components/Form/PathInput.css';

@ -1,8 +1,10 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { scrollDirections } from 'Helpers/Props'; import { kinds, scrollDirections } from 'Helpers/Props';
import Alert from 'Components/Alert';
import Button from 'Components/Link/Button'; import Button from 'Components/Link/Button';
import Link from 'Components/Link/Link';
import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import LoadingIndicator from 'Components/Loading/LoadingIndicator';
import ModalContent from 'Components/Modal/ModalContent'; import ModalContent from 'Components/Modal/ModalContent';
import ModalHeader from 'Components/Modal/ModalHeader'; import ModalHeader from 'Components/Modal/ModalHeader';
@ -101,6 +103,7 @@ class FileBrowserModalContent extends Component {
parent, parent,
directories, directories,
files, files,
isWindowsService,
onModalClose, onModalClose,
...otherProps ...otherProps
} = this.props; } = this.props;
@ -119,6 +122,16 @@ class FileBrowserModalContent extends Component {
className={styles.modalBody} className={styles.modalBody}
scrollDirection={scrollDirections.NONE} scrollDirection={scrollDirections.NONE}
> >
{
isWindowsService &&
<Alert
className={styles.mappedDrivesWarning}
kind={kinds.WARNING}
>
Mapped network drives are not available when running as a Windows Service, see the <Link className={styles.faqLink} to="https://github.com/Lidarr/Lidarr/wiki/FAQ">FAQ</Link> for more information.
</Alert>
}
<PathInput <PathInput
className={styles.pathInput} className={styles.pathInput}
placeholder="Start typing or select a path below" placeholder="Start typing or select a path below"
@ -230,6 +243,7 @@ FileBrowserModalContent.propTypes = {
currentPath: PropTypes.string.isRequired, currentPath: PropTypes.string.isRequired,
directories: PropTypes.arrayOf(PropTypes.object).isRequired, directories: PropTypes.arrayOf(PropTypes.object).isRequired,
files: PropTypes.arrayOf(PropTypes.object).isRequired, files: PropTypes.arrayOf(PropTypes.object).isRequired,
isWindowsService: PropTypes.bool.isRequired,
onFetchPaths: PropTypes.func.isRequired, onFetchPaths: PropTypes.func.isRequired,
onClearPaths: PropTypes.func.isRequired, onClearPaths: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,

@ -4,12 +4,14 @@ import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { fetchPaths, clearPaths } from 'Store/Actions/pathActions'; import { fetchPaths, clearPaths } from 'Store/Actions/pathActions';
import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector';
import FileBrowserModalContent from './FileBrowserModalContent'; import FileBrowserModalContent from './FileBrowserModalContent';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.paths, (state) => state.paths,
(paths) => { createSystemStatusSelector(),
(paths, systemStatus) => {
const { const {
isFetching, isFetching,
isPopulated, isPopulated,
@ -32,7 +34,8 @@ function createMapStateToProps() {
currentPath, currentPath,
directories, directories,
files, files,
paths: filteredPaths paths: filteredPaths,
isWindowsService: true || systemStatus.isWindows && systemStatus.mode === 'service'
}; };
} }
); );

@ -50,6 +50,7 @@ namespace Lidarr.Api.V1.Artist
IManageCommandQueue commandQueueManager, IManageCommandQueue commandQueueManager,
IRootFolderService rootFolderService, IRootFolderService rootFolderService,
RootFolderValidator rootFolderValidator, RootFolderValidator rootFolderValidator,
MappedNetworkDriveValidator mappedNetworkDriveValidator,
ArtistPathValidator artistPathValidator, ArtistPathValidator artistPathValidator,
ArtistExistsValidator artistExistsValidator, ArtistExistsValidator artistExistsValidator,
ArtistAncestorValidator artistAncestorValidator, ArtistAncestorValidator artistAncestorValidator,
@ -83,6 +84,7 @@ namespace Lidarr.Api.V1.Artist
.Cascade(CascadeMode.StopOnFirstFailure) .Cascade(CascadeMode.StopOnFirstFailure)
.IsValidPath() .IsValidPath()
.SetValidator(rootFolderValidator) .SetValidator(rootFolderValidator)
.SetValidator(mappedNetworkDriveValidator)
.SetValidator(artistPathValidator) .SetValidator(artistPathValidator)
.SetValidator(artistAncestorValidator) .SetValidator(artistAncestorValidator)
.SetValidator(systemFolderValidator) .SetValidator(systemFolderValidator)

@ -111,6 +111,10 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Lidarr.Api.V1\Lidarr.Api.V1.csproj">
<Project>{7140ff1f-79be-492f-9188-b21a050bf708}</Project>
<Name>Lidarr.Api.V1</Name>
</ProjectReference>
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj"> <ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project> <Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
<Name>NzbDrone.Common</Name> <Name>NzbDrone.Common</Name>

@ -15,6 +15,7 @@ namespace NzbDrone.Common.Disk
public class FileSystemLookupService : IFileSystemLookupService public class FileSystemLookupService : IFileSystemLookupService
{ {
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IRuntimeInfo _runtimeInfo;
private readonly HashSet<string> _setToRemove = new HashSet<string> private readonly HashSet<string> _setToRemove = new HashSet<string>
{ {
@ -46,9 +47,10 @@ namespace NzbDrone.Common.Disk
"@eadir" "@eadir"
}; };
public FileSystemLookupService(IDiskProvider diskProvider) public FileSystemLookupService(IDiskProvider diskProvider, IRuntimeInfo runtimeInfo)
{ {
_diskProvider = diskProvider; _diskProvider = diskProvider;
_runtimeInfo = runtimeInfo;
} }
public FileSystemResult LookupContents(string query, bool includeFiles, bool allowFoldersWithoutTrailingSlashes) public FileSystemResult LookupContents(string query, bool includeFiles, bool allowFoldersWithoutTrailingSlashes)
@ -88,6 +90,16 @@ namespace NzbDrone.Common.Disk
private List<FileSystemModel> GetDrives() private List<FileSystemModel> GetDrives()
{ {
return _diskProvider.GetMounts() return _diskProvider.GetMounts()
.Where(d =>
{
// Fow Windows Services, exclude mapped network drives.
if (_runtimeInfo.IsWindowsService)
{
return d.DriveType != DriveType.Network;
}
return true;
})
.Select(d => new FileSystemModel .Select(d => new FileSystemModel
{ {
Type = FileSystemEntityType.Drive, Type = FileSystemEntityType.Drive,

Loading…
Cancel
Save