From 9fbf6d1b5d42e113aac464d87ac9a17131349424 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 2 Jun 2022 11:31:41 +0100 Subject: [PATCH] fix constructors and sending of profile header with hashlist request --- .../groovy/com/muwire/core/download/DownloadManager.groovy | 5 +++-- .../groovy/com/muwire/core/download/HashListSession.groovy | 3 ++- .../groovy/com/muwire/core/download/NetworkDownloader.groovy | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy index ea47aa52..1ef023a7 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy @@ -142,7 +142,8 @@ public class DownloadManager { incompletes.mkdirs() Pieces pieces = getPieces(infoHash, size, pieceSize, sequential) - downloader = new NetworkDownloader(eventBus, this, chatServer, me, target, toShare, size, + downloader = new NetworkDownloader(eventBus, this, chatServer, me, profileSupplier, + target, toShare, size, infoHash, collectionInfoHash, pieceSize, connector, destinations, incompletes, pieces, muSettings.downloadMaxFailures) } @@ -221,7 +222,7 @@ public class DownloadManager { Pieces pieces = getPieces(infoHash, (long)json.length, json.pieceSizePow2, sequential) - downloader = new NetworkDownloader(eventBus, this, chatServer, me, file, toShare, (long)json.length, + downloader = new NetworkDownloader(eventBus, this, chatServer, me, profileSupplier, file, toShare, (long)json.length, infoHash, collectionInfoHash, json.pieceSizePow2, connector, destinations, incompletes, pieces, muSettings.downloadMaxFailures) downloader.successfulDestinations.addAll(destinations) // if it was persisted, it was successful downloader.readPieces() diff --git a/core/src/main/groovy/com/muwire/core/download/HashListSession.groovy b/core/src/main/groovy/com/muwire/core/download/HashListSession.groovy index 7c2fa642..fc2049fe 100644 --- a/core/src/main/groovy/com/muwire/core/download/HashListSession.groovy +++ b/core/src/main/groovy/com/muwire/core/download/HashListSession.groovy @@ -39,9 +39,10 @@ class HashListSession { String root = Base64.encode(infoHash.getRoot()) os.write("HASHLIST $root\r\n".getBytes(StandardCharsets.US_ASCII)) - os.write("X-Persona: $meB64\r\n\r\n".getBytes(StandardCharsets.US_ASCII)) + os.write("X-Persona: $meB64\r\n".getBytes(StandardCharsets.US_ASCII)) if (profile != null) os.write("ProfileHeader: ${profile.getHeader().toBase64()}\r\n".getBytes(StandardCharsets.US_ASCII)) + os.write("\r\n".getBytes(StandardCharsets.US_ASCII)) os.flush() String code = readTillRN(is) diff --git a/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy b/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy index e281ef3b..6e8bcf1a 100644 --- a/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy +++ b/core/src/main/groovy/com/muwire/core/download/NetworkDownloader.groovy @@ -428,7 +428,7 @@ class NetworkDownloader extends Downloader { endpoint.getOutputStream().flush() } available.removeAll(queuedPieces) - def nextSession = new DownloadSession(eventBus, me.toBase64(), pieces, infoHash, + def nextSession = new DownloadSession(eventBus, me.toBase64(), null, pieces, infoHash, endpoint, incompleteFile, pieceSize, length, available, dataSinceLastRead, browse, feed, chat, message) if (nextSession.sendRequest()) {