aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Shares/SharedFileCache.cs48
1 files changed, 1 insertions, 47 deletions
diff --git a/src/slskd/Shares/SharedFileCache.cs b/src/slskd/Shares/SharedFileCache.cs
index ad2468da..f13eaad4 100644
--- a/src/slskd/Shares/SharedFileCache.cs
+++ b/src/slskd/Shares/SharedFileCache.cs
@@ -249,7 +249,7 @@ namespace slskd.Shares
try
{
var newFiles = System.IO.Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly)
- .Select(f => new File(1, f.ReplaceFirst(share.LocalPath, share.RemotePath), new FileInfo(f).Length, Path.GetExtension(f)))
+ .Select(f => f.ToSoulseekFile(share))
.ToDictionary(f => f.Filename, f => f);
// merge the new dictionary with the rest this will overwrite any duplicate keys, but keys are the fully
@@ -462,51 +462,5 @@ namespace slskd.Shares
MaskedFiles = new Dictionary<string, File>();
State.SetValue(state => state with { Directories = 0, Files = 0 });
}
-
- private sealed class Share
- {
- public Share(string share)
- {
- Raw = share;
- IsExcluded = share.StartsWith('-') || share.StartsWith('!');
-
- if (IsExcluded)
- {
- share = share[1..];
- }
-
- // test to see whether an alias has been specified
- var matches = Regex.Matches(share, @"^\[(.*)\](.*)$");
-
- if (matches.Any())
- {
- // split the alias from the path, and validate the alias
- var groups = matches[0].Groups;
- Alias = groups[1].Value;
- LocalPath = groups[2].Value;
- }
- else
- {
- Alias = share.Split(new[] { '/', '\\' }).Last();
- LocalPath = share;
- }
-
- var parent = System.IO.Directory.GetParent(LocalPath).FullName.TrimEnd('/', '\\');
-
- Mask = Compute.MaskHash(parent);
-
- var maskedPath = LocalPath.ReplaceFirst(parent, Mask);
-
- var aliasedSegment = LocalPath[(parent.Length + 1)..];
- RemotePath = maskedPath.ReplaceFirst(aliasedSegment, Alias);
- }
-
- public string Alias { get; init; }
- public bool IsExcluded { get; init; }
- public string LocalPath { get; init; }
- public string Mask { get; init; }
- public string Raw { get; init; }
- public string RemotePath { get; init; }
- }
}
} \ No newline at end of file