From bdcb7faabe78c67a3ee5306996bf740bf408b216 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 5 Jul 2018 18:43:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Piece=20length=20can=20also=20be?= =?UTF-8?q?=201=20MiB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interfaces/ISolidFile.ts | 4 ++-- src/ssn/verify/verifySolidpkg.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/interfaces/ISolidFile.ts b/src/interfaces/ISolidFile.ts index e29794d..ef64b9f 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. 65536 for 64 KiB, 524288 for 512 KiB, and 4194304 for 4 MiB. */ - 'piece length': 65536 | 524288 | 4194304; + /** Length of one piece in bytes, i.e. 64 KiB, 256 KiB, 512 KiB, 1 MiB or 4 MiB */ + 'piece length': 65536 | 262144| 524288 | 1048576| 4194304; /** Concatenated SHA1 hashes of all pieces, where each hash is 20 bytes long. */ pieces: string; /** Whether the torrent is private, always 0. */ diff --git a/src/ssn/verify/verifySolidpkg.ts b/src/ssn/verify/verifySolidpkg.ts index ebdd383..3536028 100644 --- a/src/ssn/verify/verifySolidpkg.ts +++ b/src/ssn/verify/verifySolidpkg.ts @@ -53,9 +53,9 @@ export default function verifySolidpkg(file: ISolid, { product, from, to }: {pro } } - //64kb, 256kb, 512kb, 4mb - if (!([0x1_0000, 0x4_0000, 0x8_0000, 0x40_0000]).includes(file.info['piece length'])) { - throw new Error(`Expected piece length to be "65536", "262144", 524288" or "4194304" but it was "${file.info['piece length']}".`); + //64 KiB, 256 KiB, 512 KiB, 1 MiB, 4 MiB + if (!([0x1_0000, 0x4_0000, 0x8_0000, 0x10_0000, 0x40_0000]).includes(file.info['piece length'])) { + throw new Error(`Expected piece length to be "65536", "262144", 524288", "1048576" 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}".`);