From a48956f504db96f4295c2256d01dc0a88927a223 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Sat, 23 Jun 2018 22:21:12 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20check=20for=20piece=20leng?= =?UTF-8?q?th?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interfaces/ISolidFile.ts | 4 ++-- src/ssn/verifySolidpkg.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/interfaces/ISolidFile.ts b/src/interfaces/ISolidFile.ts index 09e52cb..0eb9cf8 100644 --- a/src/interfaces/ISolidFile.ts +++ b/src/interfaces/ISolidFile.ts @@ -8,8 +8,8 @@ interface ISolidFile { interface ISolidFileInfo { /** List of files that are part of this torrent. */ files: ISolidFile[]; - /** Length of one piece in bytes, e.g. 4194304 for 4 MiB. */ - 'piece length': number; + /** Length of one piece in bytes, e.g. 65536 for 64 KiB, and 4194304 for 4 MiB. */ + 'piece length': 65536 | 4194304; /** Concatenated hashes of all pieces. */ pieces: string; /** Whether the torrent is private, always 0. */ diff --git a/src/ssn/verifySolidpkg.ts b/src/ssn/verifySolidpkg.ts index ee1e132..d2ae425 100644 --- a/src/ssn/verifySolidpkg.ts +++ b/src/ssn/verifySolidpkg.ts @@ -41,8 +41,8 @@ export default function verifySolidpkg(file: ISolid, { product, from, to }: {pro } } - if (file.info['piece length'] !== 4194304) { - throw new Error(`Expected piece length to be "4194304" but it was "${file.info['piece length']}".`); + if (file.info['piece length'] !== 65536 && file.info['piece length'] !== 4194304 ) { + throw new Error(`Expected piece length to be "65536" or "4194304" but it was "${file.info['piece length']}".`); } if (typeof file.info.pieces !== 'string') { throw new Error(`Expected pieces to be a string but it was "${file.info.pieces}".`);