diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-06-06 18:47:26 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-06-06 18:47:26 -0500 |
| commit | 3740aaf2d59add87b87a88864ed459a94b925f5e (patch) | |
| tree | 2452556445e0b749a25d8931898d3103342b56c7 | |
| parent | ec836b73cf40226d7a754b42762f4dab44b97749 (diff) | |
| download | slskd-3740aaf2d59add87b87a88864ed459a94b925f5e.tar.gz | |
add permissions to download.destination
| -rw-r--r-- | config/slskd.example.yml | 2 | ||||
| -rw-r--r-- | src/slskd/Core/Options.cs | 37 |
2 files changed, 39 insertions, 0 deletions
diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 46ef6ec1..475ac65a 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -81,6 +81,8 @@ # destination: # subdirectory: ${SOURCE_DIRECTORY} # options: SOURCE_USERNAME, SOURCE_PATH, SOURCE_DIRECTORY, BATCH_ID, BATCH_EXTERNAL_ID, SEARCH_ID, SEARCH_TEXT # exists: rename # 'overwrite' or 'rename' +# permissions: +# mode: ~ # chmod syntax, e.g. 644, 777. does nothing on Windows. # groups: # default: # upload: 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; + } + } } } |
