diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-10 18:51:20 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-05-10 18:51:20 -0500 |
| commit | 3fb834ecb2afb7c112e191d03b20f7ae39f7a62e (patch) | |
| tree | f0b7ebef765c11f66c1abfd4ebd03262ff0a79a1 /src/slskd/Transfers/Downloads/DownloadService.cs | |
| parent | fb6dfe1498e2ca0cb0c9b65e00634169cf2d16c0 (diff) | |
| download | slskd-3fb834ecb2afb7c112e191d03b20f7ae39f7a62e.tar.gz | |
use CombineSafely
Diffstat (limited to 'src/slskd/Transfers/Downloads/DownloadService.cs')
| -rw-r--r-- | src/slskd/Transfers/Downloads/DownloadService.cs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index 184acb5d..7d9d9521 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -1046,10 +1046,11 @@ namespace slskd.Transfers.Downloads // if the transfer has an associated batch id, store the incomplete file in a directory of the same name // this is to ensure maximal safety when resuming failed downloads (otherwise we risk resuming an unrelated file) + // if there is no batch id, sanitize the username and use that var incompleteFilename = transfer.Filename.ToLocalFilename( - baseDirectory: System.IO.Path.Combine( + baseDirectory: FileSafety.CombineSafely( OptionsMonitor.CurrentValue.Directories.Incomplete, - transfer.BatchId.HasValue ? transfer.BatchId.ToString() : string.Empty)); + transfer.BatchId.HasValue ? transfer.BatchId.ToString() : transfer.Username.ReplaceInvalidFileNameCharacters())); Log.Debug("Invoking Soulseek DownloadAsync() for {Filename} from {Username}", transfer.Filename, transfer.Username); transfer.Attempts = 1; @@ -1144,7 +1145,7 @@ namespace slskd.Transfers.Downloads { // if the transfer has an associated batch id, then: // some/long/remote/path/folder/file.ext -> download_directory/batch_id/file.ext - destinationDirectory = System.IO.Path.Combine(OptionsMonitor.CurrentValue.Directories.Downloads, transfer.BatchId.Value.ToString()); + destinationDirectory = FileSafety.CombineSafely(OptionsMonitor.CurrentValue.Directories.Downloads, transfer.BatchId.Value.ToString()); } else { |
