diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-31 22:37:56 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-05-31 22:37:56 -0500 |
| commit | 18ecfac2d8dc2b5c768cc7cc2dc61fa23259417c (patch) | |
| tree | 16e853cff08b1596b633c5e1ea817a954e75779f | |
| parent | a19fcd796c3acd497388daa0e38f5fa37bf511ee (diff) | |
| download | slskd-18ecfac2d8dc2b5c768cc7cc2dc61fa23259417c.tar.gz | |
short circuit if a user has configured the root shortcut
| -rw-r--r-- | src/slskd/Transfers/Downloads/DownloadService.cs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index ee7f2efd..48c29b19 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -753,6 +753,16 @@ namespace slskd.Transfers.Downloads /// <exception cref="SlskdException">Thrown if the derivation logic produces an absolute path, or one with traversal segments.</exception> public async Task<string> DeriveDestination(Transfer transfer) { + // validation should ensure this is a relative path and that it contains no traversal segments + // we accept any type of slash in the pattern and convert it to the correct variant for the local OS + var pattern = OptionsMonitor.CurrentValue.Transfers.Download.Destination.Subdirectory; + + // users can enter '{}' if they want the files to go directly into the root of the downloads directory + if (pattern.Equals("{}", StringComparison.OrdinalIgnoreCase)) + { + return string.Empty; + } + string source_username; string source_path; string source_directory; @@ -841,10 +851,6 @@ namespace slskd.Transfers.Downloads ["SEARCH_TEXT"] = search_text, }; - // validation should ensure this is a relative path and that it contains no traversal segments - // we accept any type of slash in the pattern and convert it to the correct variant for the local OS - var pattern = OptionsMonitor.CurrentValue.Transfers.Download.Destination.Subdirectory; - // use Regex.Replace here because it makes one pass; if we chained .Replace() calls the output from one could // cascade into others and produce unintended results var destination = SubdirectoryPatternTokenRegex.Replace( @@ -1247,7 +1253,7 @@ namespace slskd.Transfers.Downloads var incompleteFilename = FileSafety.CombineSafely(incompleteDirectory, sanitizedUsername, sanitizedRemotePath, sanitizedFilename); - Log.Warning("Incomplete file for {Filename} from {Username} will be: {Filename}", FileSafety.GetFileNameSafely(transfer.Filename), transfer.Username, incompleteFilename); + Log.Debug("Incomplete file for {Filename} from {Username} will be: {IncompleteFilename}", FileSafety.GetFileNameSafely(transfer.Filename), transfer.Username, incompleteFilename); Log.Debug("Invoking Soulseek DownloadAsync() for {Filename} from {Username}", transfer.Filename, transfer.Username); transfer.Attempts = 1; |
