From e06999e5eec1616d93b34ffbab0eade617d1aaf6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jun 2026 21:31:33 +0000 Subject: Bump launch-editor from 2.6.0 to 2.14.1 in /src/web Bumps [launch-editor](https://github.com/vitejs/launch-editor) from 2.6.0 to 2.14.1. - [Commits](https://github.com/vitejs/launch-editor/compare/v2.6.0...v2.14.1) --- updated-dependencies: - dependency-name: launch-editor dependency-version: 2.14.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- src/web/package-lock.json | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/web/package-lock.json b/src/web/package-lock.json index 22d9c714..e64bc38d 100644 --- a/src/web/package-lock.json +++ b/src/web/package-lock.json @@ -14304,13 +14304,14 @@ } }, "node_modules/launch-editor": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.6.0.tgz", - "integrity": "sha512-JpDCcQnyAAzZZaZ7vEiSqL690w7dAEyLao+KC96zBplnYbJS7TYNjvM3M7y3dGz+v7aIsJk3hllWuc0kWAjyRQ==", + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.14.1.tgz", + "integrity": "sha512-QWBrQsMpH7gPr965dsKD/3cKWiNoTjpATQf++Xq63N6sKRGMwlVXz41O1IZTMfZQgBctD/K5Zt06+/I6pP6+HA==", "dev": true, + "license": "MIT", "dependencies": { - "picocolors": "^1.0.0", - "shell-quote": "^1.7.3" + "picocolors": "^1.1.1", + "shell-quote": "^1.8.4" } }, "node_modules/less": { @@ -18840,10 +18841,14 @@ } }, "node_modules/shell-quote": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", - "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.4.tgz", + "integrity": "sha512-VsC6n6vz1ihYYyZZwX7YZSF5l5x36ca17OC+a69h94YqB7X6XLwf+5MOgynYir2SLFUbl8gIYvBo8K8RoNQ6bQ==", "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } -- cgit v1.2.3 From 3740aaf2d59add87b87a88864ed459a94b925f5e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 18:47:26 -0500 Subject: add permissions to download.destination --- config/slskd.example.yml | 2 ++ src/slskd/Core/Options.cs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) 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 /// [Enum(typeof(DestinationExistsStrategy))] public string Exists { get; init; } = DestinationExistsStrategy.Rename.ToString().ToLowerInvariant(); + + /// + /// Gets the permissions to apply to downloaded files and directories. + /// + [Validate] + public DestinationPermissionsOptions Permissions { get; init; } = new DestinationPermissionsOptions(); + + /// + /// Download destination permission options. + /// + public class DestinationPermissionsOptions : IValidatableObject + { + /// + /// Gets the permissions to apply to newly created files. + /// + /// + /// Applicable to non-Windows operating systems, only. + /// + public string Mode { get; init; } + + public IEnumerable Validate(ValidationContext validationContext) + { + var results = new List(); + + 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; + } + } } } -- cgit v1.2.3 From d2f1a0ca65b77cff7b5841df1bbaf3e3342c6df0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 18:49:09 -0500 Subject: deprecate old permissions and add a validation error to flag it --- src/slskd/Core/Options.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 6436a6d2..7fb70fbb 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(); - /// - /// Gets permission options. - /// - [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; /// /// 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; -- cgit v1.2.3 From c1dd8157a683e2fb816ff0c5d06056cc0ac1e17a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 18:59:22 -0500 Subject: run chmod on directories --- src/slskd/Files/FileService.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/slskd/Files/FileService.cs b/src/slskd/Files/FileService.cs index 3b304d99..62d17f20 100644 --- a/src/slskd/Files/FileService.cs +++ b/src/slskd/Files/FileService.cs @@ -389,13 +389,15 @@ namespace slskd.Files var path = Path.GetDirectoryName(filename); - UnixFileMode? unixCreateMode = options?.UnixCreateMode ?? OptionsMonitor.CurrentValue.Permissions.File.Mode?.ToUnixFileMode(); + UnixFileMode? unixCreateMode = options?.UnixCreateMode ?? OptionsMonitor.CurrentValue.Transfers.Download.Destination.Permissions.Mode?.ToUnixFileMode(); if (!Directory.Exists(path)) { if (!OperatingSystem.IsWindows() && unixCreateMode.HasValue) { - Directory.CreateDirectory(path, unixCreateMode.Value.WithExecuteFlagsForEachReadFlag()); + var mode = unixCreateMode.Value.WithExecuteFlagsForEachReadFlag(); + Directory.CreateDirectory(path, unixCreateMode: mode); + File.SetUnixFileMode(path, mode: mode); } else { @@ -469,13 +471,15 @@ namespace slskd.Files throw new FileNotFoundException($"The specified source file does not exist", fileName: sourceFilename); } - UnixFileMode? unixCreateMode = unixFileMode ?? OptionsMonitor.CurrentValue.Permissions.File.Mode?.ToUnixFileMode(); + UnixFileMode? unixCreateMode = unixFileMode ?? OptionsMonitor.CurrentValue.Transfers.Download.Destination.Permissions.Mode?.ToUnixFileMode(); if (!Directory.Exists(destinationDirectory)) { if (!OperatingSystem.IsWindows() && unixCreateMode.HasValue) { - Directory.CreateDirectory(destinationDirectory, unixCreateMode.Value.WithExecuteFlagsForEachReadFlag()); + var mode = unixCreateMode.Value.WithExecuteFlagsForEachReadFlag(); + Directory.CreateDirectory(destinationDirectory, unixCreateMode: mode); + File.SetUnixFileMode(destinationDirectory, mode: mode); } else { -- cgit v1.2.3 From c8db4eea05780e230c52bfd53513d72f2c5c7f19 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 19:19:18 -0500 Subject: docs for download permissions --- docs/config.md | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/docs/config.md b/docs/config.md index 8848060a..c8a8fca2 100644 --- a/docs/config.md +++ b/docs/config.md @@ -117,21 +117,11 @@ Users wishing to create files with different permissions can change the umask va When running within a docker container the environment variable `SLSKD_UMASK` can be used to change the umask for the process within the container, and this will in turn change the resulting file mode on a mounted volume. -Users can optionally configure alternative permissions for files by setting the file permission mode option. It's not possible to supersede the configured umask value; setting a mode of 777, for example, will have no effect with a umask of 022. - -These options have no effect on Windows. +This option has no effect on Windows. | Command-Line | Environment Variable | Description | | ------------------------ | -----------------------------| -------------------------------------------------------------------------------- | | n/a | `SLSKD_UMASK` | When running within the slskd Docker container, the umask for the process | -| `--file-permission-mode` | `SLSKD_FILE_PERMISSION_MODE` | The permissions to apply to newly created files (chmod syntax, non-Windows only) | - -#### **YAML** -```yaml -permissions: - file: - mode: 644 # not for Windows, chmod syntax, e.g. 644, 777. can't escalate beyond umask -``` # Application Directory Configuration @@ -377,6 +367,25 @@ transfers: max_delay: 60000 # maximum time between retries, in milliseconds ``` +## Destination + +### Permissions + +On [Unix-like](https://en.wikipedia.org/wiki/Unix-like) operating systems, downloaded files will be created according to the [umask](https://en.wikipedia.org/wiki/Umask) of the process (see [Permissions](#permissions) for more info). + +Users can optionally configure alternative permissions by setting the permission mode option which, when enabled, effectively causes slskd to `chmod` files and directories with the configured mode immediately after creation. + +This option has no effect on Windows. + +#### **YAML** +```yaml +transfers: + download: + destination: + permissions: + mode: 644 # chmod syntax, e.g. 644, 777. has no effect on Windows +``` + ## Global Upload Limits Global upload limits define the number of queued, daily, and weekly uploads on a _per user_ basis. These limits behave as defaults and are applied if limits for a user's group have not been set. -- cgit v1.2.3 From 0a5274bdeb39d8aa67161ff28382c2bab626f446 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 19:40:21 -0500 Subject: bump dependencies --- src/slskd/slskd.csproj | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/slskd/slskd.csproj b/src/slskd/slskd.csproj index cf825701..cb6a7d83 100644 --- a/src/slskd/slskd.csproj +++ b/src/slskd/slskd.csproj @@ -43,41 +43,41 @@ - - + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - + - - - - - - - - + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + -- cgit v1.2.3 From ee655d70335939746a7c16f3bd9686c5e4cd2a88 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 19:42:08 -0500 Subject: update ref --- src/slskd/Transfers/Downloads/DownloadService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index c6892fc4..7c794e55 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -1218,8 +1218,8 @@ namespace slskd.Transfers.Downloads }), disposeOutputStreamOnCompletion: true); - UnixFileMode? unixFileMode = !string.IsNullOrEmpty(OptionsMonitor.CurrentValue.Permissions.File.Mode) - ? OptionsMonitor.CurrentValue.Permissions.File.Mode.ToUnixFileMode() + UnixFileMode? unixFileMode = !string.IsNullOrEmpty(OptionsMonitor.CurrentValue.Transfers.Download.Destination.Permissions.Mode) + ? OptionsMonitor.CurrentValue.Transfers.Download.Destination.Permissions.Mode.ToUnixFileMode() : null; /* -- cgit v1.2.3 From 596e6b9ee5a90384ee9c170986a9384fcd3e9f8f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 22:18:57 -0500 Subject: update imports --- src/slskd/Common/OpenAPI/ContentNegotiationOperationFilter.cs | 2 +- src/slskd/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slskd/Common/OpenAPI/ContentNegotiationOperationFilter.cs b/src/slskd/Common/OpenAPI/ContentNegotiationOperationFilter.cs index a7e7e0dc..760f7ba9 100644 --- a/src/slskd/Common/OpenAPI/ContentNegotiationOperationFilter.cs +++ b/src/slskd/Common/OpenAPI/ContentNegotiationOperationFilter.cs @@ -36,7 +36,7 @@ using System.Linq; using System.Reflection; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Formatters; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; /// diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index d4baf276..22ad585a 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -62,7 +62,7 @@ namespace slskd using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders.Physical; using Microsoft.IdentityModel.Tokens; - using Microsoft.OpenApi.Models; + using Microsoft.OpenApi; using Prometheus.DotNetRuntime; using Prometheus.SystemMetrics; using Serilog; -- cgit v1.2.3 From 69360f579b1c0679a34263290af475bba8c4060d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 22:19:13 -0500 Subject: update loki config --- src/slskd/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 22ad585a..9b7cd75e 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -67,6 +67,7 @@ namespace slskd using Prometheus.SystemMetrics; using Serilog; using Serilog.Events; + using Serilog.Formatting.Display; using Serilog.Sinks.Grafana.Loki; using Serilog.Sinks.SystemConsole.Themes; using slskd.Authentication; @@ -1236,7 +1237,7 @@ namespace slskd e => !string.IsNullOrEmpty(OptionsAtStartup.Logger.Loki), config => config.GrafanaLoki( OptionsAtStartup.Logger.Loki ?? string.Empty, - outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")) + textFormatter: new MessageTemplateTextFormatter("[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"))) .WriteTo.Sink(new DelegatingSink(logEvent => { string message = default; -- cgit v1.2.3 From e71eade0131b16c01f77637088c1e44ee07b3af6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 6 Jun 2026 22:40:41 -0500 Subject: conditional config of loki --- src/slskd/Program.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 9b7cd75e..39c0d2ac 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -1235,9 +1235,15 @@ namespace slskd retainedFileTimeLimit: TimeSpan.FromDays(OptionsAtStartup.Retention.Logs)))) .WriteTo.Conditional( e => !string.IsNullOrEmpty(OptionsAtStartup.Logger.Loki), - config => config.GrafanaLoki( - OptionsAtStartup.Logger.Loki ?? string.Empty, - textFormatter: new MessageTemplateTextFormatter("[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"))) + config => + { + if (!string.IsNullOrEmpty(OptionsAtStartup.Logger.Loki)) + { + config.GrafanaLoki( + OptionsAtStartup.Logger.Loki, + textFormatter: new MessageTemplateTextFormatter("[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")); + } + }) .WriteTo.Sink(new DelegatingSink(logEvent => { string message = default; -- cgit v1.2.3 From 0145a4d87ebe474aba82e2ad136eb9f5d652cc12 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 7 Jun 2026 13:50:21 -0500 Subject: use the default message formatter for Loki (previous format prevented capture of properties) --- src/slskd/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 39c0d2ac..9a2914ea 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -1008,6 +1008,7 @@ namespace slskd services.AddSwaggerGen(options => { options.DescribeAllParametersInCamelCase(); + options.CustomSchemaIds(type => type.FullName); options.SwaggerDoc("v0", new OpenApiInfo { Version = "v0", @@ -1217,6 +1218,7 @@ namespace slskd .MinimumLevel.Override("slskd.Authentication.PassthroughAuthenticationHandler", LogEventLevel.Warning) .MinimumLevel.Override("slskd.Authentication.ApiKeyAuthenticationHandler", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning) // bump this down to Information to show SQL + .Enrich.WithProperty("App", AppName) .Enrich.WithProperty("InstanceName", OptionsAtStartup.InstanceName) .Enrich.WithProperty("InvocationId", InvocationId) .Enrich.WithProperty("ProcessId", ProcessId) @@ -1239,9 +1241,7 @@ namespace slskd { if (!string.IsNullOrEmpty(OptionsAtStartup.Logger.Loki)) { - config.GrafanaLoki( - OptionsAtStartup.Logger.Loki, - textFormatter: new MessageTemplateTextFormatter("[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")); + config.GrafanaLoki(OptionsAtStartup.Logger.Loki); } }) .WriteTo.Sink(new DelegatingSink(logEvent => -- cgit v1.2.3 From 3080725e2596d2963ef85a69f50070b914e5642c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 7 Jun 2026 13:53:06 -0500 Subject: bump test deps, too --- tests/slskd.Tests.Unit/slskd.Tests.Unit.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/slskd.Tests.Unit/slskd.Tests.Unit.csproj b/tests/slskd.Tests.Unit/slskd.Tests.Unit.csproj index d1e76222..7278bd6d 100644 --- a/tests/slskd.Tests.Unit/slskd.Tests.Unit.csproj +++ b/tests/slskd.Tests.Unit/slskd.Tests.Unit.csproj @@ -7,14 +7,14 @@ - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all -- cgit v1.2.3 From 1273205967f9427e6453b4064bdf549205ba106c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 7 Jun 2026 15:07:44 -0500 Subject: resolve warnings about X509 API changes --- src/slskd/Common/Cryptography/X509.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slskd/Common/Cryptography/X509.cs b/src/slskd/Common/Cryptography/X509.cs index bed224cf..b003decf 100644 --- a/src/slskd/Common/Cryptography/X509.cs +++ b/src/slskd/Common/Cryptography/X509.cs @@ -64,7 +64,7 @@ namespace slskd.Cryptography new DateTimeOffset(DateTime.UtcNow.AddDays(-1)), new DateTimeOffset(DateTime.UtcNow.AddDays(36500))); - return new X509Certificate2(certificate.Export(X509ContentType.Pkcs12, password), password, x509KeyStorageFlags); + return X509CertificateLoader.LoadPkcs12(certificate.Export(X509ContentType.Pkcs12, password), password, x509KeyStorageFlags); } /// @@ -80,7 +80,7 @@ namespace slskd.Cryptography try { - _ = new X509Certificate2(fileName, password); + _ = X509CertificateLoader.LoadPkcs12FromFile(fileName, password); return true; } catch (Exception ex) -- cgit v1.2.3 From 360e1c33739166b35f58f82acc8a9475cf8271a1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 7 Jun 2026 15:22:09 -0500 Subject: fully deprecate old permissions objects --- src/slskd/Core/Options.cs | 51 ----------------- tests/slskd.Tests.Unit/Files/FileServiceTests.cs | 72 ++++++++++++++++++------ 2 files changed, 54 insertions(+), 69 deletions(-) diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index f35a56df..d1062a2c 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -705,57 +705,6 @@ namespace slskd } } - /// - /// Permission options. - /// - public class PermissionsOptions - { - /// - /// Gets file permission options. - /// - [Validate] - public FileOptions File { get; init; } = new FileOptions(); - - /// - /// File permission options. - /// - public class FileOptions : IValidatableObject - { - /// - /// Gets the permissions to apply to newly created files. - /// - /// - /// Applicable to non-Windows operating systems, only. - /// - [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; } - - /// - /// Extended validation. - /// - /// - /// - public IEnumerable Validate(ValidationContext validationContext) - { - var results = new List(); - - 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; - } - } - } - /// /// Directory options. /// diff --git a/tests/slskd.Tests.Unit/Files/FileServiceTests.cs b/tests/slskd.Tests.Unit/Files/FileServiceTests.cs index 7bb0bfdd..d6c30316 100644 --- a/tests/slskd.Tests.Unit/Files/FileServiceTests.cs +++ b/tests/slskd.Tests.Unit/Files/FileServiceTests.cs @@ -155,11 +155,17 @@ namespace slskd.Tests.Unit.Files OptionsMonitorMock.Setup(o => o.CurrentValue).Returns(new Options { - Permissions = new Options.PermissionsOptions + Transfers = new Options.TransfersOptions { - File = new Options.PermissionsOptions.FileOptions + Download = new Options.TransfersOptions.GlobalDownloadOptions { - Mode = mode, + Destination = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions + { + Permissions = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions.DestinationPermissionsOptions + { + Mode = mode, + } + } } } }); @@ -204,11 +210,17 @@ namespace slskd.Tests.Unit.Files OptionsMonitorMock.Setup(o => o.CurrentValue).Returns(new Options { - Permissions = new Options.PermissionsOptions + Transfers = new Options.TransfersOptions { - File = new Options.PermissionsOptions.FileOptions + Download = new Options.TransfersOptions.GlobalDownloadOptions { - Mode = mode, + Destination = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions + { + Permissions = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions.DestinationPermissionsOptions + { + Mode = mode, + } + } } } }); @@ -262,11 +274,17 @@ namespace slskd.Tests.Unit.Files OptionsMonitorMock.Setup(o => o.CurrentValue).Returns(new Options { - Permissions = new Options.PermissionsOptions + Transfers = new Options.TransfersOptions { - File = new Options.PermissionsOptions.FileOptions + Download = new Options.TransfersOptions.GlobalDownloadOptions { - Mode = mode, + Destination = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions + { + Permissions = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions.DestinationPermissionsOptions + { + Mode = mode, + } + } } } }); @@ -316,11 +334,17 @@ namespace slskd.Tests.Unit.Files OptionsMonitorMock.Setup(o => o.CurrentValue).Returns(new Options { - Permissions = new Options.PermissionsOptions + Transfers = new Options.TransfersOptions { - File = new Options.PermissionsOptions.FileOptions + Download = new Options.TransfersOptions.GlobalDownloadOptions { - Mode = mode, + Destination = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions + { + Permissions = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions.DestinationPermissionsOptions + { + Mode = mode, + } + } } } }); @@ -367,11 +391,17 @@ namespace slskd.Tests.Unit.Files OptionsMonitorMock.Setup(o => o.CurrentValue).Returns(new Options { - Permissions = new Options.PermissionsOptions + Transfers = new Options.TransfersOptions { - File = new Options.PermissionsOptions.FileOptions + Download = new Options.TransfersOptions.GlobalDownloadOptions { - Mode = optionsMode, + Destination = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions + { + Permissions = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions.DestinationPermissionsOptions + { + Mode = optionsMode, + } + } } } }); @@ -401,11 +431,17 @@ namespace slskd.Tests.Unit.Files OptionsMonitorMock.Setup(o => o.CurrentValue).Returns(new Options { - Permissions = new Options.PermissionsOptions + Transfers = new Options.TransfersOptions { - File = new Options.PermissionsOptions.FileOptions + Download = new Options.TransfersOptions.GlobalDownloadOptions { - Mode = optionsMode, + Destination = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions + { + Permissions = new Options.TransfersOptions.GlobalDownloadOptions.DestinationOptions.DestinationPermissionsOptions + { + Mode = optionsMode, + } + } } } }); -- cgit v1.2.3