aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-11-01 09:50:17 -0500
committerJP Dillingham <jp@dillingham.me>2022-11-01 09:50:17 -0500
commitcdd4e53a5dd202828ae568e64830905a6f66beeb (patch)
treec6410dcdffefb36274de127eb07498a2bb8a4750
parentca1cc49261e7835966dac8a936e782ba654a3dbf (diff)
downloadslskd-cdd4e53a5dd202828ae568e64830905a6f66beeb.tar.gz
fix paths
-rw-r--r--src/slskd/Shares/ShareService.cs9
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs1
2 files changed, 5 insertions, 5 deletions
diff --git a/src/slskd/Shares/ShareService.cs b/src/slskd/Shares/ShareService.cs
index 85cd2796..b36c7898 100644
--- a/src/slskd/Shares/ShareService.cs
+++ b/src/slskd/Shares/ShareService.cs
@@ -15,7 +15,6 @@
// along with this program. If not, see https://www.gnu.org/licenses/.
// </copyright>
-using System.IO;
using Microsoft.Extensions.Options;
namespace slskd.Shares
@@ -145,7 +144,7 @@ namespace slskd.Shares
if (share != null)
{
- prefix = share.RemotePath + Path.DirectorySeparatorChar;
+ prefix = share.RemotePath + (share.RemotePath.EndsWith('\\') ? string.Empty : '\\');
}
// Soulseek requires that each directory in the tree have an entry in the list returned in a browse response. if
@@ -161,12 +160,12 @@ namespace slskd.Shares
var files = AllRepositories.SelectMany(r => r.ListFiles(prefix, includeFullPath: true));
var groups = files
- .GroupBy(file => Path.GetDirectoryName(file.Filename))
+ .GroupBy(file => file.Filename.GetNormalizedDirectoryName())
.Select(group => new Directory(group.Key, group.Select(f =>
{
return new File(
f.Code,
- Path.GetFileName(f.Filename), // we can send the full path, or just the filename. save bandwidth and omit the path.
+ f.Filename.GetNormalizedFileName(), // we can send the full path, or just the filename. save bandwidth and omit the path.
f.Size,
f.Extension,
f.Attributes);
@@ -308,7 +307,7 @@ namespace slskd.Shares
/// <returns>The summary information.</returns>
public Task<(int Directories, int Files)> SummarizeShareAsync(Share share)
{
- var prefix = share.RemotePath + Path.DirectorySeparatorChar;
+ var prefix = share.RemotePath + (share.RemotePath.EndsWith('\\') ? string.Empty : '\\');
var dirs = AllRepositories.Select(r => r.CountDirectories(prefix)).Sum();
var files = AllRepositories.Select(r => r.CountFiles(prefix)).Sum();
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index 2f06b665..1d1b6dfc 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -451,6 +451,7 @@ namespace slskd.Transfers.Downloads
System.Diagnostics.Stopwatch sw = default;
+ // todo: remove this. or check that Path.GetFileName works as expected if it is to be kept
if (experimental)
{
sw = new System.Diagnostics.Stopwatch();