diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-06-07 16:40:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-07 16:40:56 -0500 |
| commit | d3dbc50b44ae12a7ae9f10bbef074adcbe75cfa5 (patch) | |
| tree | 16b5c69f3363b4e2517b117b5c4eaaae3b223a41 /src/slskd/Core | |
| parent | ba9cf1be9c795ac0ef4ff72935427de362c9cdd0 (diff) | |
| parent | ec0dd1430f8987fc7cc2550975ff4ec3d80a3147 (diff) | |
| download | slskd-d3dbc50b44ae12a7ae9f10bbef074adcbe75cfa5.tar.gz | |
Merge branch 'master' into master
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/Options.cs | 100 |
1 files changed, 44 insertions, 56 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 29d37806..d1062a2c 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -235,11 +235,8 @@ namespace slskd [Validate] public RelayOptions Relay { get; init; } = new RelayOptions(); - /// <summary> - /// Gets permission options. - /// </summary> - [Validate] - public PermissionsOptions Permissions { get; init; } = new PermissionsOptions(); + [Obsolete("temporary sentinel to warn users about breaking change. use Transfers.Download.Destination.Permissions instead.")] + public object Permissions { get; init; } = null; /// <summary> /// Gets directory options. @@ -364,6 +361,11 @@ namespace slskd { results.Add(new ValidationResult("The 'integration' key has been renamed to 'integrations'. Add an 's' to the end of the key to remove this error (no other changes were made)")); } + + if (Permissions is not null) + { + results.Add(new ValidationResult("The 'permissions' keys have been moved under a new 'destination' key under transfers -> download, and the behavior has changed. See https://github.com/slskd/slskd/pull/1756 for details")); + } #pragma warning restore CS0618 // Type or member is obsolete return results; @@ -704,57 +706,6 @@ namespace slskd } /// <summary> - /// Permission options. - /// </summary> - public class PermissionsOptions - { - /// <summary> - /// Gets file permission options. - /// </summary> - [Validate] - public FileOptions File { get; init; } = new FileOptions(); - - /// <summary> - /// File permission options. - /// </summary> - public class FileOptions : IValidatableObject - { - /// <summary> - /// Gets the permissions to apply to newly created files. - /// </summary> - /// <remarks> - /// Applicable to non-Windows operating systems, only. - /// </remarks> - [Argument(default, "file-permission-mode")] - [EnvironmentVariable("FILE_PERMISSION_MODE")] - [Description("the permissions to apply to newly created files (chmod syntax, non-Windows only)")] - public string Mode { get; init; } - - /// <summary> - /// Extended validation. - /// </summary> - /// <param name="validationContext"></param> - /// <returns></returns> - 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; - } - } - } - - /// <summary> /// Directory options. /// </summary> public class DirectoriesOptions @@ -1082,6 +1033,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; + } + } } } |
