From 18ecfac2d8dc2b5c768cc7cc2dc61fa23259417c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 31 May 2026 22:37:56 -0500 Subject: short circuit if a user has configured the root shortcut --- src/slskd/Transfers/Downloads/DownloadService.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') 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 /// Thrown if the derivation logic produces an absolute path, or one with traversal segments. public async Task 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; -- cgit v1.2.3