diff --git a/src/cdn/funcs/saveResponse.ts b/src/cdn/funcs/saveResponse.ts index 31da4ab..f6933d9 100644 --- a/src/cdn/funcs/saveResponse.ts +++ b/src/cdn/funcs/saveResponse.ts @@ -57,7 +57,7 @@ export default function saveResponse( //Return file reader //TODO: need to automatically delete file once it is no longer used //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); }); } diff --git a/src/interfaces/ISolidFile.ts b/src/interfaces/ISolidFile.ts index ef64b9f..e6e3c66 100644 --- a/src/interfaces/ISolidFile.ts +++ b/src/interfaces/ISolidFile.ts @@ -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}/` */ reliable: string; /** Always '0' or '1' */ - 'reliable-id': '0' | '1'; + 'reliable-id': '0' | '1' | '2'; /** Contains further information about this torrent, including the list of files. */ info: ISolidFileInfo; } diff --git a/src/ssn/streams/getFileFromDisks.ts b/src/ssn/streams/getFileFromDisks.ts new file mode 100644 index 0000000..d4ed99c --- /dev/null +++ b/src/ssn/streams/getFileFromDisks.ts @@ -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) { + //... +} diff --git a/src/ssn/verify/verifySolidpkg.ts b/src/ssn/verify/verifySolidpkg.ts index 3536028..1318959 100644 --- a/src/ssn/verify/verifySolidpkg.ts +++ b/src/ssn/verify/verifySolidpkg.ts @@ -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}/`) { throw new Error(`Expected reliable URL but it was "${file.reliable}".`); } - if (file['reliable-id'] !== '0' && file['reliable-id'] !== '1') { - throw new Error(`Expected reliable-id to be "0" or "1" but it was "${file['reliable-id']}".`); + if (!(['0', '1', '2']).includes(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) {