From aba8787f7648d87ab728fc6546a44849c03e31fe Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 20 Aug 2021 21:50:21 -0500 Subject: sort by full name --- src/slskd/Application/SharedFileCache.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/slskd/Application/SharedFileCache.cs') diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs index 4e0d5cd0..2b9c4d79 100644 --- a/src/slskd/Application/SharedFileCache.cs +++ b/src/slskd/Application/SharedFileCache.cs @@ -99,7 +99,12 @@ namespace slskd directories.AddOrUpdate(group.Name, group, (_, _) => group); } - return directories.Values.OrderBy(f => f.Name[8..]); + Console.WriteLine(directories.Values.ToJson()); + + return directories.Values.OrderBy(f => { + Console.WriteLine($"Sorting by {f.Name}"); + return f.Name[8..]; + }); } /// @@ -206,7 +211,6 @@ namespace slskd Log.Warning("Failed to scan files in directory {Directory}: {Message}", directory, ex.Message); } - current++; State.SetValue(state => state with { FillProgress = current / (double)unmaskedDirectories.Count, Files = files.Count }); } -- cgit v1.2.3 From f5f534c23f39599bb83b69a022ba141b6168ff8c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 20 Aug 2021 22:23:45 -0500 Subject: use split instead of Uri() --- src/slskd/Application/SharedFileCache.cs | 2 +- src/slskd/Options.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/slskd/Application/SharedFileCache.cs') diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs index 2b9c4d79..5ef9be64 100644 --- a/src/slskd/Application/SharedFileCache.cs +++ b/src/slskd/Application/SharedFileCache.cs @@ -365,7 +365,7 @@ namespace slskd } else { - Alias = new Uri(share).Segments.Last(); + Alias = share.Split(new[] { '/', '\\' }).Last(); LocalPath = share; } diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 62bc0a6c..ec1eab06 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -280,7 +280,7 @@ namespace slskd return (share, Compute.MaskHash(Directory.GetParent(matches[0].Groups[3].Value).FullName), matches[0].Groups[2].Value, matches[0].Groups[3].Value); } - return (share, Compute.MaskHash(Directory.GetParent(share).FullName), new Uri(share).Segments.Last(), share); + return (share, Compute.MaskHash(Directory.GetParent(share).FullName), share.Split(new[] { '/', '\\' }).Last(), share); } var digestedShared = Shared -- cgit v1.2.3 From 810f8660bcc435bfb6dd4e1be99b8194462b263a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 21 Aug 2021 07:25:30 -0500 Subject: stop replacing forward slashes in file paths --- src/slskd/Application/SharedFileCache.cs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/slskd/Application/SharedFileCache.cs') diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs index 5ef9be64..06442797 100644 --- a/src/slskd/Application/SharedFileCache.cs +++ b/src/slskd/Application/SharedFileCache.cs @@ -99,12 +99,7 @@ namespace slskd directories.AddOrUpdate(group.Name, group, (_, _) => group); } - Console.WriteLine(directories.Values.ToJson()); - - return directories.Values.OrderBy(f => { - Console.WriteLine($"Sorting by {f.Name}"); - return f.Name[8..]; - }); + return directories.Values.OrderBy(f => f.Name[8..]); } /// @@ -191,7 +186,7 @@ namespace slskd try { var newFiles = System.IO.Directory.GetFiles(directory, "*", SearchOption.TopDirectoryOnly) - .Select(f => new File(1, f.Replace("/", @"\").ReplaceFirst(share.LocalPath, share.RemotePath), new FileInfo(f).Length, Path.GetExtension(f))) + .Select(f => new File(1, f.ReplaceFirst(share.LocalPath, share.RemotePath), new FileInfo(f).Length, Path.GetExtension(f))) .ToDictionary(f => f.Filename, f => f); // merge the new dictionary with the rest this will overwrite any duplicate keys, but keys are the fully @@ -373,15 +368,8 @@ namespace slskd var maskedPath = LocalPath.ReplaceFirst(System.IO.Directory.GetParent(LocalPath).FullName, Mask); - if (!string.IsNullOrEmpty(Alias)) - { - var aliasedSegment = LocalPath[(System.IO.Directory.GetParent(LocalPath).FullName.Length + 1)..]; - RemotePath = maskedPath.ReplaceFirst(aliasedSegment, Alias); - } - else - { - RemotePath = LocalPath.ReplaceFirst(System.IO.Directory.GetParent(LocalPath).FullName, Mask); - } + var aliasedSegment = LocalPath[(System.IO.Directory.GetParent(LocalPath).FullName.Length + 1)..]; + RemotePath = maskedPath.ReplaceFirst(aliasedSegment, Alias); } public string Alias { get; init; } -- cgit v1.2.3