aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-06-06 18:47:26 -0500
committerJP Dillingham <jp@dillingham.me>2026-06-06 18:47:26 -0500
commit3740aaf2d59add87b87a88864ed459a94b925f5e (patch)
tree2452556445e0b749a25d8931898d3103342b56c7 /src
parentec836b73cf40226d7a754b42762f4dab44b97749 (diff)
downloadslskd-3740aaf2d59add87b87a88864ed459a94b925f5e.tar.gz
add permissions to download.destination
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Options.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index e76f5d2f..6436a6d2 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1082,6 +1082,43 @@ namespace slskd
/// </summary>
[Enum(typeof(DestinationExistsStrategy))]
public string Exists { get; init; } = DestinationExistsStrategy.Rename.ToString().ToLowerInvariant();
+
+ /// <summary>
+ /// Gets the permissions to apply to downloaded files and directories.
+ /// </summary>
+ [Validate]
+ public DestinationPermissionsOptions Permissions { get; init; } = new DestinationPermissionsOptions();
+
+ /// <summary>
+ /// Download destination permission options.
+ /// </summary>
+ public class DestinationPermissionsOptions : IValidatableObject
+ {
+ /// <summary>
+ /// Gets the permissions to apply to newly created files.
+ /// </summary>
+ /// <remarks>
+ /// Applicable to non-Windows operating systems, only.
+ /// </remarks>
+ public string Mode { get; init; }
+
+ public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
+ {
+ var results = new List<ValidationResult>();
+
+ if (!string.IsNullOrEmpty(Mode))
+ {
+ var regEx = new Regex("^[0-7]{3,4}$", RegexOptions.Compiled);
+
+ if (!regEx.IsMatch(Mode))
+ {
+ results.Add(new ValidationResult($"Field {nameof(Mode)} is invalid. Specify a three- or four-character string consisting of only 0-7 (chmod syntax, [0]000-[7]777, inclusive)"));
+ }
+ }
+
+ return results;
+ }
+ }
}
}