Add logging to debug why the download doesnt progress when deployed to dokku

This commit is contained in:
Peter Stockings
2026-01-01 17:22:53 +11:00
parent 134c4b36c9
commit cbe39e76a2
2 changed files with 5 additions and 1 deletions

View File

@@ -212,6 +212,7 @@ export class TorrentSession {
const actualHash = crypto.createHash('sha1').update(fullPiece).digest();
if (expectedHash && Buffer.compare(actualHash, expectedHash) === 0) {
console.log(`[Engine] Piece ${index} VERIFIED! Progress: ${this.progress}%`);
this.bitfield.set(index);
this.storage?.writePiece(index, this.pieceLength, fullPiece);
this.reassemblers.delete(index);
@@ -224,7 +225,9 @@ export class TorrentSession {
console.log(`[Engine] Torrent ${this.hash} download COMPLETED!`);
}
} else {
// Hash failed, restart piece
const expectedHex = expectedHash ? Buffer.from(expectedHash).toString('hex').slice(0, 8) : 'unknown';
const actualHex = actualHash.toString('hex').slice(0, 8);
console.error(`[Engine] Piece ${index} Hash Mismatch! Expected ${expectedHex}... Got ${actualHex}...`);
this.reassemblers.delete(index);
}
}

View File

@@ -124,6 +124,7 @@ export class PeerWorker {
const begin = payload.readUInt32BE(4);
const block = payload.slice(8);
this.pendingRequests.delete(`${index}:${begin}`);
// console.log(`[Worker] Received block ${index}:${begin} (${block.length} bytes) from ${this.host}`);
this.onPiece(index, begin, block);
this.activeRequests--;
break;