diff --git a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs b/src/NzbDrone.Api/RootFolders/RootFolderModule.cs index a4c0f892b..a2c4daed8 100644 --- a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs +++ b/src/NzbDrone.Api/RootFolders/RootFolderModule.cs @@ -17,7 +17,8 @@ namespace NzbDrone.Api.RootFolders PathExistsValidator pathExistsValidator, DroneFactoryValidator droneFactoryValidator, MappedNetworkDriveValidator mappedNetworkDriveValidator, - StartupFolderValidator startupFolderValidator) + StartupFolderValidator startupFolderValidator, + FolderWritableValidator folderWritableValidator) : base(signalRBroadcaster) { _rootFolderService = rootFolderService; @@ -34,7 +35,8 @@ namespace NzbDrone.Api.RootFolders .SetValidator(droneFactoryValidator) .SetValidator(mappedNetworkDriveValidator) .SetValidator(startupFolderValidator) - .SetValidator(pathExistsValidator); + .SetValidator(pathExistsValidator) + .SetValidator(folderWritableValidator); } private RootFolderResource GetRootFolder(int id) diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index a5a945d9a..75fd71535 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -1036,6 +1036,7 @@ + diff --git a/src/NzbDrone.Core/Validation/Paths/FolderWritableValidator.cs b/src/NzbDrone.Core/Validation/Paths/FolderWritableValidator.cs new file mode 100644 index 000000000..bf88cf3be --- /dev/null +++ b/src/NzbDrone.Core/Validation/Paths/FolderWritableValidator.cs @@ -0,0 +1,24 @@ +using System; +using FluentValidation.Validators; +using NzbDrone.Common.Disk; + +namespace NzbDrone.Core.Validation.Paths +{ + public class FolderWritableValidator : PropertyValidator + { + private readonly IDiskProvider _diskProvider; + + public FolderWritableValidator(IDiskProvider diskProvider) + : base($"Folder is not writable by user {Environment.UserName}") + { + _diskProvider = diskProvider; + } + + protected override bool IsValid(PropertyValidatorContext context) + { + if (context.PropertyValue == null) return false; + + return (_diskProvider.FolderWritable(context.PropertyValue.ToString())); + } + } +} \ No newline at end of file diff --git a/src/UI/.idea/inspectionProfiles/Project_Default.xml b/src/UI/.idea/inspectionProfiles/Project_Default.xml index 7f20f79f3..7aba4e3c2 100644 --- a/src/UI/.idea/inspectionProfiles/Project_Default.xml +++ b/src/UI/.idea/inspectionProfiles/Project_Default.xml @@ -85,7 +85,6 @@