From e5d362836ce8892487864170abdc31fc032989c5 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 4 Jun 2026 08:07:48 -0500 Subject: fix junk --- src/slskd/Common/FileSafety.cs | 5 ---- .../Common/Validation/RelativePathAttribute.cs | 31 ++-------------------- 2 files changed, 2 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/FileSafety.cs b/src/slskd/Common/FileSafety.cs index b72d3749..a07de6d1 100644 --- a/src/slskd/Common/FileSafety.cs +++ b/src/slskd/Common/FileSafety.cs @@ -176,11 +176,8 @@ public static class FileSafety return false; } - Console.WriteLine($"IsPathAbsolute? path: {path}, os: {os}, iswindows? {System.OperatingSystem.IsWindows()}"); - if (os.HasValue ? os.Value == OperatingSystem.Windows : System.OperatingSystem.IsWindows()) { - Console.WriteLine("Windows!"); // Windows drive-letter path: X:\ or X:/ // X:foo is relative on windows if (path.Length >= 3 @@ -200,8 +197,6 @@ public static class FileSafety return false; } - Console.WriteLine("Linux!"); - // Unix/Linux/macOS absolute paths and UNC paths with forward slashes start with / if (path.StartsWith('/')) { diff --git a/src/slskd/Common/Validation/RelativePathAttribute.cs b/src/slskd/Common/Validation/RelativePathAttribute.cs index 62185a42..1bdbd4fb 100644 --- a/src/slskd/Common/Validation/RelativePathAttribute.cs +++ b/src/slskd/Common/Validation/RelativePathAttribute.cs @@ -83,38 +83,11 @@ namespace slskd.Validation // OS == OperatingSystem.All or .Any; if (!FileSafety.IsPathRelative(path, os: OperatingSystem.Linux) || !FileSafety.IsPathRelative(path, os: OperatingSystem.Windows)) { - // this can only be exercised via unit tests; OSPlatform can't be passeed as an attribute argument - // so, this takes precedent over PlatformAgnostic - if (!FileSafety.IsPathRelative(path, os: OS)) - { - return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path."); - } - } - else - { - if (!PlatformAgnostic) - { - if (!FileSafety.IsPathRelative(path, os: null)) // this OS - { - return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path."); - } - } - else - { - if (!FileSafety.IsPathRelative(path, os: OSPlatform.Linux)) - { - return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path."); - } - - if (!FileSafety.IsPathRelative(path, os: OSPlatform.Windows)) - { - return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path."); - } - } + return new ValidationResult($"The {validationContext.DisplayName} field must be a relative path."); } } return ValidationResult.Success; } } -} +} \ No newline at end of file -- cgit v1.2.3