FolderWritableValidator
Fixed: Information in UI when attempting to add a root folder that is not writable Fixes #1280
This commit is contained in:
parent
ea0982ecae
commit
67ff871cf6
|
@ -17,7 +17,8 @@ namespace NzbDrone.Api.RootFolders
|
||||||
PathExistsValidator pathExistsValidator,
|
PathExistsValidator pathExistsValidator,
|
||||||
DroneFactoryValidator droneFactoryValidator,
|
DroneFactoryValidator droneFactoryValidator,
|
||||||
MappedNetworkDriveValidator mappedNetworkDriveValidator,
|
MappedNetworkDriveValidator mappedNetworkDriveValidator,
|
||||||
StartupFolderValidator startupFolderValidator)
|
StartupFolderValidator startupFolderValidator,
|
||||||
|
FolderWritableValidator folderWritableValidator)
|
||||||
: base(signalRBroadcaster)
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
_rootFolderService = rootFolderService;
|
_rootFolderService = rootFolderService;
|
||||||
|
@ -34,7 +35,8 @@ namespace NzbDrone.Api.RootFolders
|
||||||
.SetValidator(droneFactoryValidator)
|
.SetValidator(droneFactoryValidator)
|
||||||
.SetValidator(mappedNetworkDriveValidator)
|
.SetValidator(mappedNetworkDriveValidator)
|
||||||
.SetValidator(startupFolderValidator)
|
.SetValidator(startupFolderValidator)
|
||||||
.SetValidator(pathExistsValidator);
|
.SetValidator(pathExistsValidator)
|
||||||
|
.SetValidator(folderWritableValidator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RootFolderResource GetRootFolder(int id)
|
private RootFolderResource GetRootFolder(int id)
|
||||||
|
|
|
@ -1036,6 +1036,7 @@
|
||||||
<Compile Include="Validation\NzbDroneValidationState.cs" />
|
<Compile Include="Validation\NzbDroneValidationState.cs" />
|
||||||
<Compile Include="Validation\Paths\MappedNetworkDriveValidator.cs" />
|
<Compile Include="Validation\Paths\MappedNetworkDriveValidator.cs" />
|
||||||
<Compile Include="Validation\Paths\DroneFactoryValidator.cs" />
|
<Compile Include="Validation\Paths\DroneFactoryValidator.cs" />
|
||||||
|
<Compile Include="Validation\Paths\FolderWritableValidator.cs" />
|
||||||
<Compile Include="Validation\Paths\PathExistsValidator.cs" />
|
<Compile Include="Validation\Paths\PathExistsValidator.cs" />
|
||||||
<Compile Include="Validation\Paths\PathValidator.cs" />
|
<Compile Include="Validation\Paths\PathValidator.cs" />
|
||||||
<Compile Include="Validation\Paths\StartupFolderValidator.cs" />
|
<Compile Include="Validation\Paths\StartupFolderValidator.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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,7 +85,6 @@
|
||||||
<option name="m_minLength" value="1" />
|
<option name="m_minLength" value="1" />
|
||||||
<option name="m_maxLength" value="32" />
|
<option name="m_maxLength" value="32" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="LossyEncoding" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
<inspection_tool class="NegatedIfStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="NegatedIfStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="NestedAssignmentJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="NestedAssignmentJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="NestedFunctionCallJS" enabled="false" level="ERROR" enabled_by_default="false" />
|
<inspection_tool class="NestedFunctionCallJS" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||||
|
|
|
@ -6,4 +6,3 @@
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue