From 25245ca526b436b00b2150c02e0eb946df548e93 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 8 May 2024 22:44:52 -0500 Subject: stub options --- src/slskd/Core/Options.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 81dc09f6..3fef8a94 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -209,6 +209,12 @@ namespace slskd [Validate] public RelayOptions Relay { get; init; } = new RelayOptions(); + /// + /// Gets file options. + /// + [Validate] + public FilesOptions Files { get; init; } = new FilesOptions(); + /// /// Gets directory options. /// @@ -602,6 +608,33 @@ namespace slskd } } + /// + /// File options. + /// + public class FilesOptions : IValidatableObject + { + public string Permissions { get; init; } + public string Umask { get; init; } + + public IEnumerable Validate(ValidationContext validationContext) + { + var regEx = new Regex("[0-7]{3}", RegexOptions.Compiled); + var results = new List(); + + if (!string.IsNullOrEmpty(Permissions) && !regEx.IsMatch(Permissions)) + { + results.Add(new ValidationResult($"Field {nameof(Permissions)} is invalid. Specify a three-character string consisting of only 0-7 (000-777, inclusive)")); + } + + if (!string.IsNullOrEmpty(Umask) && !regEx.IsMatch(Umask)) + { + results.Add(new ValidationResult($"Field {nameof(Umask)} is invalid. Specify a three-character string consisting of only 0-7 (000-777, inclusive)")); + } + + return results; + } + } + /// /// Directory options. /// -- cgit v1.2.3