🎨 Reliable-id can be 2

This commit is contained in:
C-3PO 2018-07-05 20:27:58 +02:00
parent bdcb7faabe
commit 60fe546d31
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
4 changed files with 19 additions and 4 deletions

View file

@ -57,7 +57,7 @@ export default function saveResponse(
//Return file reader //Return file reader
//TODO: need to automatically delete file once it is no longer used //TODO: need to automatically delete file once it is no longer used
//TODO: need to provide methods to seek through file //TODO: need to provide methods to seek through file
const stream = fs.createReadStream(tempFileName, { encoding: 'binary' }); const stream = fs.createReadStream(tempFileName, { encoding: 'binary' }); //TODO: we may need to remove encoding since mentioning encoding automatically switches to string format
return resolve(stream); return resolve(stream);
}); });
} }

View file

@ -32,7 +32,7 @@ interface ISolid {
/** The URL where the files from this torrent are stored, in the format `http://cdn-patch.swtor.com/patch/${product}/${product}_${from}to${to}/` */ /** The URL where the files from this torrent are stored, in the format `http://cdn-patch.swtor.com/patch/${product}/${product}_${from}to${to}/` */
reliable: string; reliable: string;
/** Always '0' or '1' */ /** Always '0' or '1' */
'reliable-id': '0' | '1'; 'reliable-id': '0' | '1' | '2';
/** Contains further information about this torrent, including the list of files. */ /** Contains further information about this torrent, including the list of files. */
info: ISolidFileInfo; info: ISolidFileInfo;
} }

View file

@ -0,0 +1,15 @@
import * as stream from 'stream';
interface IGetFileFromDisksOptions {
/** Number of the disk where the local file header starts */
diskStart: number;
/** Offset into the start of the disk where the local file header starts. */
offset: number;
/** Length of the stored file (compressed size + optional 12 byte encryption header), but excluding the length of the local file header. */
storedSize: number;
}
/** Takes a list of ReadableStreams (the disks), as well as the offset and length, and returns a stream for just one file. */
export default function getFileFromDisks(disks: stream.Readable[], { diskStart, offset, storedSize }: IGetFileFromDisksOptions) {
//...
}

View file

@ -17,8 +17,8 @@ export default function verifySolidpkg(file: ISolid, { product, from, to }: {pro
if (file.reliable !== `http://cdn-patch.swtor.com/patch/${product}/${product}_${from}to${to}/`) { if (file.reliable !== `http://cdn-patch.swtor.com/patch/${product}/${product}_${from}to${to}/`) {
throw new Error(`Expected reliable URL but it was "${file.reliable}".`); throw new Error(`Expected reliable URL but it was "${file.reliable}".`);
} }
if (file['reliable-id'] !== '0' && file['reliable-id'] !== '1') { if (!(['0', '1', '2']).includes(file['reliable-id'])) {
throw new Error(`Expected reliable-id to be "0" or "1" but it was "${file['reliable-id']}".`); throw new Error(`Expected reliable-id to be "0", "1" or "2" but it was "${file['reliable-id']}".`);
} }
if (file.info === undefined) { if (file.info === undefined) {