aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-05-17 18:27:32 -0500
committerJP Dillingham <jp@dillingham.me>2024-05-17 18:27:32 -0500
commitd221780782481d931daa11b04e14229accceee6d (patch)
tree4792389e63bb3ccb35f3724e2f2dff1ccb26caf7 /src
parentad43047f4f57a26d0ab5225f22b2a78ab491a12c (diff)
downloadslskd-d221780782481d931daa11b04e14229accceee6d.tar.gz
move config under Global
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Options.cs82
-rw-r--r--src/slskd/Files/FileService.cs2
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs2
3 files changed, 43 insertions, 43 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index 37b333ba..e67be138 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -210,12 +210,6 @@ namespace slskd
public RelayOptions Relay { get; init; } = new RelayOptions();
/// <summary>
- /// Gets file options.
- /// </summary>
- [Validate]
- public FilesOptions Files { get; init; } = new FilesOptions();
-
- /// <summary>
/// Gets directory options.
/// </summary>
[Validate]
@@ -609,41 +603,6 @@ namespace slskd
}
/// <summary>
- /// File options.
- /// </summary>
- public class FilesOptions : IValidatableObject
- {
- /// <summary>
- /// Gets the permissions to apply to newly created files.
- /// </summary>
- /// <remarks>
- /// Applicable to non-Windows operating systems, only.
- /// </remarks>
- [Argument(default, "file-permissions")]
- [EnvironmentVariable("FILE_PERMISSIONS")]
- [Description("the permissions to apply to newly created files (chmod syntax, non-Windows only)")]
- public string Permissions { get; init; } = "644";
-
- /// <summary>
- /// Extended validation.
- /// </summary>
- /// <param name="validationContext"></param>
- /// <returns></returns>
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- var regEx = new Regex("^[0-7]{3,4}$", RegexOptions.Compiled);
- var results = new List<ValidationResult>();
-
- if (!regEx.IsMatch(Permissions))
- {
- results.Add(new ValidationResult($"Field {nameof(Permissions)} is invalid. Specify a three-character string consisting of only 0-7 (chmod syntax, 000-777, inclusive)"));
- }
-
- return results;
- }
- }
-
- /// <summary>
/// Directory options.
/// </summary>
public class DirectoriesOptions
@@ -894,6 +853,47 @@ namespace slskd
[Description("the total download speed limit")]
[Range(1, int.MaxValue)]
public int SpeedLimit { get; init; } = int.MaxValue;
+
+ /// <summary>
+ /// Gets downloaded file options.
+ /// </summary>
+ [Validate]
+ public GlobalDownloadFileOptions File { get; init; } = new GlobalDownloadFileOptions();
+ }
+
+ /// <summary>
+ /// File options.
+ /// </summary>
+ public class GlobalDownloadFileOptions : IValidatableObject
+ {
+ /// <summary>
+ /// Gets the permissions to apply to newly downloaded files.
+ /// </summary>
+ /// <remarks>
+ /// Applicable to non-Windows operating systems, only.
+ /// </remarks>
+ [Argument(default, "downloaded-file-permissions")]
+ [EnvironmentVariable("DOWNLOADED_FILE_PERMISSIONS")]
+ [Description("the permissions to apply to newly downloaded files (chmod syntax, non-Windows only)")]
+ public string Permissions { get; init; } = "644";
+
+ /// <summary>
+ /// Extended validation.
+ /// </summary>
+ /// <param name="validationContext"></param>
+ /// <returns></returns>
+ public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
+ {
+ var regEx = new Regex("^[0-7]{3,4}$", RegexOptions.Compiled);
+ var results = new List<ValidationResult>();
+
+ if (!regEx.IsMatch(Permissions))
+ {
+ results.Add(new ValidationResult($"Field {nameof(Permissions)} is invalid. Specify a three- or four-character string consisting of only 0-7 (chmod syntax, [0]000-[7]777, inclusive)"));
+ }
+
+ return results;
+ }
}
}
diff --git a/src/slskd/Files/FileService.cs b/src/slskd/Files/FileService.cs
index 91dadba6..3bcdd04f 100644
--- a/src/slskd/Files/FileService.cs
+++ b/src/slskd/Files/FileService.cs
@@ -276,7 +276,7 @@ namespace slskd.Files
if (!OperatingSystem.IsWindows())
{
streamOptions.UnixCreateMode = options?.UnixCreateMode
- ?? OptionsMonitor.CurrentValue.Files.Permissions?.ToUnixFileMode()
+ ?? OptionsMonitor.CurrentValue.Global.Download.File.Permissions?.ToUnixFileMode()
?? UnixFileMode.None;
Log.Debug("Setting Unix file mode to {Mode}", streamOptions.UnixCreateMode);
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index f848928f..e6410691 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -296,7 +296,7 @@ namespace slskd.Transfers.Downloads
Access = System.IO.FileAccess.Write,
Mode = System.IO.FileMode.Create, // overwrites file if it exists
Share = System.IO.FileShare.None, // exclusive access for the duration of the download
- UnixCreateMode = OptionsMonitor.CurrentValue.Files.Permissions.ToUnixFileMode(),
+ UnixCreateMode = OptionsMonitor.CurrentValue.Global.Download.File.Permissions.ToUnixFileMode(),
})),
size: file.Size,
startOffset: 0,