mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-25 22:37:27 -04:00
933c23ce57
(cherry picked from commit a117001de673e80abd90d54a34a7c86292b3a649)
32 lines
964 B
C#
32 lines
964 B
C#
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)
|
|
{
|
|
_diskProvider = diskProvider;
|
|
}
|
|
|
|
protected override string GetDefaultMessageTemplate() => "Folder '{path}' is not writable by user '{user}'";
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
{
|
|
if (context.PropertyValue == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
context.MessageFormatter.AppendArgument("path", context.PropertyValue.ToString());
|
|
context.MessageFormatter.AppendArgument("user", Environment.UserName);
|
|
|
|
return _diskProvider.FolderWritable(context.PropertyValue.ToString());
|
|
}
|
|
}
|
|
}
|