diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-08-21 07:39:59 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-21 07:39:59 -0500 |
| commit | 48019b8b14d113e44e4aadaff5452c4921a3690f (patch) | |
| tree | 10ce496a78d6e74d856fb9db02c5b99d6fe9c7d1 /src/slskd/Application/SharedFileCache.cs | |
| parent | 928724e62943ad2f026098d66d1e700514237b0b (diff) | |
| parent | 2965cd9684915624f851f9f7960b695b918f3128 (diff) | |
| download | slskd-48019b8b14d113e44e4aadaff5452c4921a3690f.tar.gz | |
Merge pull request #163 from slskd/fix-share
Improve shared file handling on non-Windows OS
Diffstat (limited to 'src/slskd/Application/SharedFileCache.cs')
| -rw-r--r-- | src/slskd/Application/SharedFileCache.cs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs index a3d7da93..575e7379 100644 --- a/src/slskd/Application/SharedFileCache.cs +++ b/src/slskd/Application/SharedFileCache.cs @@ -186,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 @@ -206,7 +206,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 }); } @@ -361,7 +360,7 @@ namespace slskd } else { - Alias = new Uri(share).Segments.Last(); + Alias = share.Split(new[] { '/', '\\' }).Last(); LocalPath = share; } @@ -369,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; } |
