🐛 Allow for 256kb piece lengths
This commit is contained in:
parent
58963160c2
commit
397e1fd172
4 changed files with 9 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
export default function failWithError(usage: string, msg?: string) {
|
||||
if (msg !== undefined) {
|
||||
process.stderr.write(`${msg.trim()}\n`);
|
||||
process.stderr.write(`Error: ${msg.trim()}\n`);
|
||||
}
|
||||
process.stderr.write(`Usage: ${usage} \n`);
|
||||
process.exit(1);
|
||||
|
|
|
@ -7,13 +7,13 @@ import verifyProductName from './ssn/verify/verifyProductName';
|
|||
const failFunction = failWithError.bind(null, 'node dist/getManifest.js <product>');
|
||||
|
||||
if (process.argv.length !== 3) {
|
||||
failFunction(`Error: Expected 1 argument but ${process.argv.length - 2} arguments were supplied.`);
|
||||
failFunction(`Expected 1 argument but ${process.argv.length - 2} arguments were supplied.`);
|
||||
}
|
||||
|
||||
//Check that product name is valid
|
||||
const product = process.argv[2];
|
||||
if (!verifyProductName(product)) {
|
||||
failFunction(`Error: "${product} is not a valid product name.`);
|
||||
failFunction(`"${product} is not a valid product name.`);
|
||||
}
|
||||
|
||||
//Get manifest and write output to console
|
||||
|
|
|
@ -7,23 +7,23 @@ import verifyProductName from './ssn/verify/verifyProductName';
|
|||
const failFunction = failWithError.bind(null, 'node dist/getSolidpkg.js <product> <from> <to>');
|
||||
|
||||
if (process.argv.length !== 5) {
|
||||
failFunction(`Error: Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`);
|
||||
failFunction(`Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`);
|
||||
}
|
||||
|
||||
//Check that product name is valid
|
||||
const product = process.argv[2];
|
||||
if (!verifyProductName(product)) {
|
||||
failFunction(`Error: "${product.substring(0, 300)}" is not a valid product name.`);
|
||||
failFunction(`"${product.substring(0, 300)}" is not a valid product name.`);
|
||||
}
|
||||
|
||||
//Check that from and to are valid numbers
|
||||
const from = process.argv[3];
|
||||
const to = process.argv[4];
|
||||
if (!from.match(/^(-1|0|[1-9][0-9]{0,2})$/)) {
|
||||
failFunction(`Error: from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`);
|
||||
failFunction(`from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`);
|
||||
}
|
||||
if (!to.match(/^(0|[1-9][0-9]{0,2})$/)) {
|
||||
failFunction(`Error: to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`);
|
||||
failFunction(`to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`);
|
||||
}
|
||||
|
||||
//Get solidpkg and write output to console
|
||||
|
|
|
@ -53,8 +53,8 @@ export default function verifySolidpkg(file: ISolid, { product, from, to }: {pro
|
|||
}
|
||||
}
|
||||
|
||||
if (!([0x1_0000, 0x8_0000, 0x40_0000]).includes(file.info['piece length'])) {
|
||||
throw new Error(`Expected piece length to be "65536", "524288" or "4194304" but it was "${file.info['piece length']}".`);
|
||||
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']}".`);
|
||||
}
|
||||
if (typeof file.info.pieces !== 'string') {
|
||||
throw new Error(`Expected pieces to be a string but it was "${file.info.pieces}".`);
|
||||
|
|
Loading…
Reference in a new issue