aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2023-07-25 09:21:20 -0500
committerJP Dillingham <jp@dillingham.me>2023-07-25 09:21:20 -0500
commit337e47b84b3456ab402c5b49d6811e7ad2cafc0b (patch)
tree26c2b83b6757be4a772efa58ce46fda3163c6aba /src
parent863209c67d6fe3cce2ae8a6b0346ec4dbda286da (diff)
downloadslskd-337e47b84b3456ab402c5b49d6811e7ad2cafc0b.tar.gz
fix crash validating shares
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Options.cs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index c438c03c..2ee21733 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -652,17 +652,19 @@ namespace slskd
{
var results = new List<ValidationResult>();
+ var directories = Directories ?? Enumerable.Empty<string>();
+
bool IsBlankPath(string share) => Regex.IsMatch(share.LocalizePath(), @"^(!|-){0,1}(\[.*\])$");
- Directories.Where(share => IsBlankPath(share)).ToList()
+ directories?.Where(share => IsBlankPath(share)).ToList()
.ForEach(blank => results.Add(new ValidationResult($"Share {blank} doees not specify a path")));
bool IsRootMount(string share) => Regex.IsMatch(share.LocalizePath(), @"^(!|-){0,1}(\[.*\])/$");
- Directories.Where(share => IsRootMount(share)).ToList()
+ directories?.Where(share => IsRootMount(share)).ToList()
.ForEach(blank => results.Add(new ValidationResult($"Share {blank} specifies a root mount, which is not supported.")));
// starts with '/', 'X:', or '\\'
bool IsAbsolutePath(string share) => Regex.IsMatch(share.LocalizePath(), @"^(!|-){0,1}(\[.*\])?(\/|[a-zA-Z]:|\\\\).*$");
- Directories.Where(share => !IsAbsolutePath(share)).ToList()
+ directories?.Where(share => !IsAbsolutePath(share)).ToList()
.ForEach(relativePath => results.Add(new ValidationResult($"Share {relativePath} contains a relative path; only absolute paths are supported.")));
(string Raw, string Alias, string Path) Digest(string share)
@@ -677,7 +679,7 @@ namespace slskd
return (share, share.Split(new[] { '/', '\\' }).Last(), share);
}
- var digestedShared = Directories
+ var digestedShared = directories
.Select(share => Digest(share.TrimEnd('/', '\\')))
.ToHashSet();