aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Core
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Core')
-rw-r--r--src/slskd/Core/Options.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index bac86ea2..8123404e 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1029,6 +1029,12 @@ namespace slskd
public RetryOptions Retry { get; init; } = new RetryOptions();
/// <summary>
+ /// Gets download destination options.
+ /// </summary>
+ [Validate]
+ public DestinationOptions Destination { get; init; } = new DestinationOptions();
+
+ /// <summary>
/// Download retry options.
/// </summary>
public class RetryOptions
@@ -1057,6 +1063,63 @@ namespace slskd
[Enum(typeof(RetryPartialStrategy))]
public string Partial { get; init; } = RetryPartialStrategy.Resume.ToString().ToLowerInvariant();
}
+
+ /// <summary>
+ /// Download destination options.
+ /// </summary>
+ public class DestinationOptions
+ {
+ /// <summary>
+ /// Gets the destination subdirectory for the files in the batch.
+ /// </summary>
+ [RelativePath]
+ [NonTraversingPath]
+ [String(AllowNull = true, AllowEmpty = false, AllowWhiteSpace = false, MinimumLength = 1)]
+ public string Subdirectory { get; init; } = "{SOURCE_DIRECTORY}";
+
+ /// <summary>
+ /// Gets the strategy for handling conflicting filenames on disk.
+ /// </summary>
+ [Enum(typeof(DestinationConflictStrategy))]
+ public string Conflict { get; init; } = DestinationConflictStrategy.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;
+ }
+ }
+ }
}
/// <summary>