aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-04-24 18:02:49 -0500
committerJP Dillingham <jp@dillingham.me>2026-04-24 18:02:49 -0500
commit0a3dc3abcd712c570efa54abf4af775e16b221dd (patch)
treef9c38478c75cb7225fbda1c87335e4422f75d3d1 /src
parent0248581eecad4a9ab6c633ad751ba0ec450660ef (diff)
downloadslskd-0a3dc3abcd712c570efa54abf4af775e16b221dd.tar.gz
move completed transfers to batch folder, if present
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Transfers/Downloads/DownloadService.cs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs
index c24d43da..d4d8004a 100644
--- a/src/slskd/Transfers/Downloads/DownloadService.cs
+++ b/src/slskd/Transfers/Downloads/DownloadService.cs
@@ -1117,8 +1117,28 @@ namespace slskd.Transfers.Downloads
Log.Debug("Successfully updated Transfer for {Filename} from {Username} (state: {State}, progress: {Progress})", transfer.Filename, transfer.Username, transfer.State, transfer.PercentComplete);
- // move the file from incomplete to complete
- var destinationDirectory = System.IO.Path.GetDirectoryName(transfer.Filename.ToLocalFilename(baseDirectory: OptionsMonitor.CurrentValue.Directories.Downloads));
+ /*
+ move the file from incomplete to complete
+
+ users have a lot of strong opinions about this!
+ */
+ string destinationDirectory;
+
+ if (transfer.BatchId is not null)
+ {
+ // 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());
+ }
+ else
+ {
+ // ToLocalFilename chops all but the containing folder off of the path and localizes slashes, so:
+ // some/long/remote/path/folder/file.ext -> folder/file.ext -> download_directory/folder/file.ext
+ // this is "legacy" behavior that will be familiar to most Soulseek users
+ destinationDirectory = System.IO.Path.GetDirectoryName(transfer.Filename.ToLocalFilename(baseDirectory: OptionsMonitor.CurrentValue.Directories.Downloads));
+ }
+
+ Log.Debug("Destination directory for {Filename}: {Destination}", transfer.Filename, destinationDirectory);
var finalFilename = Files.MoveFile(
sourceFilename: transfer.Filename.ToLocalFilename(baseDirectory: OptionsMonitor.CurrentValue.Directories.Incomplete),