diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-03-09 08:00:29 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-09 08:00:29 -0600 |
| commit | 05db04ea6e9d1526a8e6799d8f1aacb7e6a4e5e8 (patch) | |
| tree | bf9fae7794a866ecba46bc58aca42aba737ad338 /src | |
| parent | a70f8f82afd1a288952e2bcab6bec9f03efb1972 (diff) | |
| parent | 462577ea90527c41a6615791873b258ea59370a1 (diff) | |
| download | slskd-05db04ea6e9d1526a8e6799d8f1aacb7e6a4e5e8.tar.gz | |
Merge pull request #52 from slskd/fix-uploads
Use requested filename when uploading files
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Service.cs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/slskd/Service.cs b/src/slskd/Service.cs index cd8e0fda..41b74a25 100644 --- a/src/slskd/Service.cs +++ b/src/slskd/Service.cs @@ -287,18 +287,19 @@ namespace slskd private Task EnqueueDownloadAction(string username, IPEndPoint endpoint, string filename, ITransferTracker tracker) { _ = endpoint; - filename = filename.ToLocalOSPath(); - var fileInfo = new FileInfo(filename); + var localFilename = filename.ToLocalOSPath(); + var fileInfo = new FileInfo(localFilename); if (!fileInfo.Exists) { - Console.WriteLine($"[UPLOAD REJECTED] File {filename} not found."); + Console.WriteLine($"[UPLOAD REJECTED] File {localFilename} not found."); throw new DownloadEnqueueException($"File not found."); } if (tracker.TryGet(TransferDirection.Upload, username, filename, out _)) { - // in this case, a re-requested file is a no-op. normally we'd want to respond with a PlaceInQueueResponse + // in this case, a re-requested file is a no-op. normally we'd want to respond with a + // PlaceInQueueResponse Console.WriteLine($"[UPLOAD RE-REQUESTED] [{username}/{filename}]"); return Task.CompletedTask; } @@ -307,12 +308,12 @@ namespace slskd var cts = new CancellationTokenSource(); var topts = new TransferOptions(stateChanged: (e) => tracker.AddOrUpdate(e, cts), progressUpdated: (e) => tracker.AddOrUpdate(e, cts), governor: (t, c) => Task.Delay(1, c)); - // accept all download requests, and begin the upload immediately. normally there would be an internal queue, and - // uploads would be handled separately. + // accept all download requests, and begin the upload immediately. + // normally there would be an internal queue, and uploads would be handled separately. Task.Run(async () => { using var stream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read); - await Client.UploadAsync(username, fileInfo.FullName, fileInfo.Length, stream, options: topts, cancellationToken: cts.Token); + await Client.UploadAsync(username, filename, fileInfo.Length, stream, options: topts, cancellationToken: cts.Token); }).ContinueWith(t => { Console.WriteLine($"[UPLOAD FAILED] {t.Exception}"); |
