aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application/SharedFileCache.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-09-20 22:16:25 -0500
committerGitHub <noreply@github.com>2021-09-20 22:16:25 -0500
commit597b44ff36d68a7263b7df60bc9a666994e5f82b (patch)
treef568ca55d4e3d259386c8c8ed60a8e81b81c5198 /src/slskd/Application/SharedFileCache.cs
parent2b41f25f2572a3ec72d439251abef9c8cd6a4d86 (diff)
parentf0231b87dc5d06933876be2f57fa0b27753c355b (diff)
downloadslskd-597b44ff36d68a7263b7df60bc9a666994e5f82b.tar.gz
Merge pull request #201 from slskd/path-fix
Fix share path issues when the parent directory is a root
Diffstat (limited to 'src/slskd/Application/SharedFileCache.cs')
-rw-r--r--src/slskd/Application/SharedFileCache.cs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs
index 7bd30d2a..52c75ed1 100644
--- a/src/slskd/Application/SharedFileCache.cs
+++ b/src/slskd/Application/SharedFileCache.cs
@@ -406,11 +406,13 @@ namespace slskd
LocalPath = share;
}
- Mask = Compute.MaskHash(System.IO.Directory.GetParent(LocalPath).FullName);
+ var parent = System.IO.Directory.GetParent(LocalPath).FullName.TrimEnd('/', '\\');
- var maskedPath = LocalPath.ReplaceFirst(System.IO.Directory.GetParent(LocalPath).FullName, Mask);
+ Mask = Compute.MaskHash(parent);
- var aliasedSegment = LocalPath[(System.IO.Directory.GetParent(LocalPath).FullName.Length + 1)..];
+ var maskedPath = LocalPath.ReplaceFirst(parent, Mask);
+
+ var aliasedSegment = LocalPath[(parent.Length + 1)..];
RemotePath = maskedPath.ReplaceFirst(aliasedSegment, Alias);
}