diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-19 18:54:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-19 18:54:29 -0500 |
| commit | 03b35a5ababfd7bc2d0af053d8622a14cdd6b8fe (patch) | |
| tree | a54b0a5e109af900ff7eb586c46ce6d6d3c591e2 /src | |
| parent | b4e6a6009fad6b6cdf890526dda0825464c22e94 (diff) | |
| parent | 33c37b535d4ce68313b77d3a466933c8b047e825 (diff) | |
| download | slskd-03b35a5ababfd7bc2d0af053d8622a14cdd6b8fe.tar.gz | |
Merge pull request #1737 from slskd/incomplete-bug
Fix bug handling incomplete filenames
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Transfers/Downloads/DownloadService.cs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index 89b8a6a7..83e91ced 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -1049,13 +1049,10 @@ namespace slskd.Transfers.Downloads ? OptionsMonitor.CurrentValue.Permissions.File.Mode.ToUnixFileMode() : null; - // 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 + // store incomplete files under a username subdirectory to prevent collisions between users + // and to make it safe to resume partial downloads without risking picking up an unrelated file var incompleteFilename = transfer.Filename.ToLocalFilename( - baseDirectory: FileSafety.CombineSafely( - OptionsMonitor.CurrentValue.Directories.Incomplete, - transfer.BatchId.HasValue ? transfer.BatchId.ToString() : transfer.Username.ReplaceInvalidFileNameCharacters())); + baseDirectory: FileSafety.CombineSafely(OptionsMonitor.CurrentValue.Directories.Incomplete, transfer.Username.ReplaceInvalidFileNameCharacters())); Log.Debug("Invoking Soulseek DownloadAsync() for {Filename} from {Username}", transfer.Filename, transfer.Username); transfer.Attempts = 1; @@ -1163,7 +1160,7 @@ namespace slskd.Transfers.Downloads Log.Debug("Destination directory for {Filename}: {Destination}", transfer.Filename, destinationDirectory); var finalFilename = Files.MoveFile( - sourceFilename: transfer.Filename.ToLocalFilename(baseDirectory: OptionsMonitor.CurrentValue.Directories.Incomplete), + sourceFilename: incompleteFilename, destinationDirectory: destinationDirectory, unixFileMode: unixFileMode, overwrite: false, |
