From 68aaa49e9f59705b1d1ee503a3a15a32e11786bc Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 4 Sep 2018 22:38:48 -0400 Subject: [PATCH] Fixed: Filter mapped drives when running from service --- .../FileBrowser/FileBrowserModalContent.css | 12 ++++++++++++ .../FileBrowser/FileBrowserModalContent.js | 16 +++++++++++++++- .../FileBrowserModalContentConnector.js | 7 +++++-- src/Lidarr.Api.V1/Artist/ArtistModule.cs | 2 ++ .../NzbDrone.Common.Test.csproj | 4 ++++ .../Disk/FileSystemLookupService.cs | 14 +++++++++++++- 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css index 80aac9a06..9ae11f0bd 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css @@ -5,6 +5,18 @@ flex-direction: column; } +.mappedDrivesWarning { + composes: alert from 'Components/Alert.css'; + + margin: 0; + margin-bottom: 20px; +} + +.faqLink { + color: $alertWarningColor; + font-weight: bold; +} + .pathInput { composes: pathInputWrapper from 'Components/Form/PathInput.css'; diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.js b/frontend/src/Components/FileBrowser/FileBrowserModalContent.js index d1ddeab25..502ecfaee 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.js +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.js @@ -1,8 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; 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 Link from 'Components/Link/Link'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import ModalContent from 'Components/Modal/ModalContent'; import ModalHeader from 'Components/Modal/ModalHeader'; @@ -101,6 +103,7 @@ class FileBrowserModalContent extends Component { parent, directories, files, + isWindowsService, onModalClose, ...otherProps } = this.props; @@ -119,6 +122,16 @@ class FileBrowserModalContent extends Component { className={styles.modalBody} scrollDirection={scrollDirections.NONE} > + { + isWindowsService && + + Mapped network drives are not available when running as a Windows Service, see the FAQ for more information. + + } + state.paths, - (paths) => { + createSystemStatusSelector(), + (paths, systemStatus) => { const { isFetching, isPopulated, @@ -32,7 +34,8 @@ function createMapStateToProps() { currentPath, directories, files, - paths: filteredPaths + paths: filteredPaths, + isWindowsService: true || systemStatus.isWindows && systemStatus.mode === 'service' }; } ); diff --git a/src/Lidarr.Api.V1/Artist/ArtistModule.cs b/src/Lidarr.Api.V1/Artist/ArtistModule.cs index e41e6a587..01d728464 100644 --- a/src/Lidarr.Api.V1/Artist/ArtistModule.cs +++ b/src/Lidarr.Api.V1/Artist/ArtistModule.cs @@ -50,6 +50,7 @@ namespace Lidarr.Api.V1.Artist IManageCommandQueue commandQueueManager, IRootFolderService rootFolderService, RootFolderValidator rootFolderValidator, + MappedNetworkDriveValidator mappedNetworkDriveValidator, ArtistPathValidator artistPathValidator, ArtistExistsValidator artistExistsValidator, ArtistAncestorValidator artistAncestorValidator, @@ -83,6 +84,7 @@ namespace Lidarr.Api.V1.Artist .Cascade(CascadeMode.StopOnFirstFailure) .IsValidPath() .SetValidator(rootFolderValidator) + .SetValidator(mappedNetworkDriveValidator) .SetValidator(artistPathValidator) .SetValidator(artistAncestorValidator) .SetValidator(systemFolderValidator) diff --git a/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj b/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj index f91797c08..c07df85ba 100644 --- a/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj +++ b/src/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj @@ -111,6 +111,10 @@ + + {7140ff1f-79be-492f-9188-b21a050bf708} + Lidarr.Api.V1 + {F2BE0FDF-6E47-4827-A420-DD4EF82407F8} NzbDrone.Common diff --git a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs index dfef2578c..819407cd2 100644 --- a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs +++ b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs @@ -15,6 +15,7 @@ namespace NzbDrone.Common.Disk public class FileSystemLookupService : IFileSystemLookupService { private readonly IDiskProvider _diskProvider; + private readonly IRuntimeInfo _runtimeInfo; private readonly HashSet _setToRemove = new HashSet { @@ -46,9 +47,10 @@ namespace NzbDrone.Common.Disk "@eadir" }; - public FileSystemLookupService(IDiskProvider diskProvider) + public FileSystemLookupService(IDiskProvider diskProvider, IRuntimeInfo runtimeInfo) { _diskProvider = diskProvider; + _runtimeInfo = runtimeInfo; } public FileSystemResult LookupContents(string query, bool includeFiles, bool allowFoldersWithoutTrailingSlashes) @@ -88,6 +90,16 @@ namespace NzbDrone.Common.Disk private List GetDrives() { 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 { Type = FileSystemEntityType.Drive,