🐛 Allow piece length of 512 KiB

This commit is contained in:
C-3PO 2018-06-24 02:28:04 +02:00
parent 42db8d36a6
commit 6709315b68
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
2 changed files with 4 additions and 4 deletions

View file

@ -8,8 +8,8 @@ interface ISolidFile {
interface ISolidFileInfo { interface ISolidFileInfo {
/** List of files that are part of this torrent. */ /** List of files that are part of this torrent. */
files: ISolidFile[]; files: ISolidFile[];
/** Length of one piece in bytes, e.g. 65536 for 64 KiB, and 4194304 for 4 MiB. */ /** Length of one piece in bytes, e.g. 65536 for 64 KiB, 524288 for 512 KiB, and 4194304 for 4 MiB. */
'piece length': 65536 | 4194304; 'piece length': 65536 | 524288 | 4194304;
/** Concatenated SHA1 hashes of all pieces, where each hash is 20 bytes long. */ /** Concatenated SHA1 hashes of all pieces, where each hash is 20 bytes long. */
pieces: string; pieces: string;
/** Whether the torrent is private, always 0. */ /** Whether the torrent is private, always 0. */

View file

@ -41,8 +41,8 @@ export default function verifySolidpkg(file: ISolid, { product, from, to }: {pro
} }
} }
if (file.info['piece length'] !== 65536 && file.info['piece length'] !== 4194304 ) { if (!([0x1_0000, 0x8_0000, 0x40_0000]).includes(file.info['piece length'])) {
throw new Error(`Expected piece length to be "65536" or "4194304" but it was "${file.info['piece length']}".`); throw new Error(`Expected piece length to be "65536", "524288" or "4194304" but it was "${file.info['piece length']}".`);
} }
if (typeof file.info.pieces !== 'string') { if (typeof file.info.pieces !== 'string') {
throw new Error(`Expected pieces to be a string but it was "${file.info.pieces}".`); throw new Error(`Expected pieces to be a string but it was "${file.info.pieces}".`);