🐎 Use executable for installation instead of JS
This commit is contained in:
parent
cd3bef0017
commit
6a4c73ba7f
3 changed files with 34 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { Product } from '../interfaces/ISettings';
|
import { Product } from '../interfaces/ISettings';
|
||||||
import verifyProductName from '../ssn/verify/verifyProductName';
|
import verifyProductName from './verify/verifyProductName';
|
||||||
|
|
||||||
/** For the given release in the given product, returns from which releases we can patch to this release. */
|
/** For the given release in the given product, returns from which releases we can patch to this release. */
|
||||||
function getFromList({ product, to: releaseTo}: {product: Product, to: number}) {
|
function getFromList({ product, to: releaseTo}: {product: Product, to: number}) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Product } from '../interfaces/ISettings';
|
||||||
import { SsnDiffType } from '../interfaces/ISsnFileEntry';
|
import { SsnDiffType } from '../interfaces/ISsnFileEntry';
|
||||||
import extractFileAsStream from './extractFileAsStream';
|
import extractFileAsStream from './extractFileAsStream';
|
||||||
import getSolidpkg from './getSolidpkg';
|
import getSolidpkg from './getSolidpkg';
|
||||||
|
import launch from './patcher-installer/launch';
|
||||||
import readSsnFile from './reader/readSsnFile';
|
import readSsnFile from './reader/readSsnFile';
|
||||||
import getFileFromDisks from './streams/getFileFromDisks';
|
import getFileFromDisks from './streams/getFileFromDisks';
|
||||||
import verifyPatch from './verify/verifyPatch';
|
import verifyPatch from './verify/verifyPatch';
|
||||||
|
@ -83,15 +84,15 @@ export default async function getPatch({ product, from, to, sourceDirectory, tar
|
||||||
//Extract newly added files
|
//Extract newly added files
|
||||||
fileEntries.filter((file) => file.diffType === SsnDiffType.NewFile).forEach(async (file) => {
|
fileEntries.filter((file) => file.diffType === SsnDiffType.NewFile).forEach(async (file) => {
|
||||||
try {
|
try {
|
||||||
//extract file
|
//create file write stream
|
||||||
const fileStream = await getFileFromDisks(diskFilenames, { diskStart: file.diskNumberStart, offset: file.offset, length: file.compressedSize });
|
|
||||||
const fileContents = await extractFileAsStream(file, fileStream);
|
|
||||||
|
|
||||||
//write to disk
|
|
||||||
const outputName = path.join(targetDir, file.name);
|
const outputName = path.join(targetDir, file.name);
|
||||||
await createDirRecursively(path.dirname(outputName));
|
await createDirRecursively(path.dirname(outputName));
|
||||||
const outputStream = fs.createWriteStream(outputName);
|
const outputStream = fs.createWriteStream(outputName);
|
||||||
fileContents.pipe(outputStream);
|
|
||||||
|
//start installation
|
||||||
|
await launch(diskFilenames[file.diskNumberStart], file.offset, file.compressedSize, file.decryptionKeys, outputStream);
|
||||||
|
|
||||||
|
outputStream.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Could not extract file "${file.name}"`, error);
|
console.error(`Could not extract file "${file.name}"`, error);
|
||||||
}
|
}
|
||||||
|
|
26
src/ssn/patcher-installer/launch.ts
Normal file
26
src/ssn/patcher-installer/launch.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import * as childProcess from 'child_process';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
const processPath = path.join(__dirname, '../../lib/patcher-installer');
|
||||||
|
|
||||||
|
export default function launchProcess(diskFile: string, offset: number, compressedSize: number, decryptionKeys: [number, number, number] | undefined, outputStream: fs.WriteStream) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const parameters = [
|
||||||
|
diskFile,
|
||||||
|
offset,
|
||||||
|
compressedSize,
|
||||||
|
];
|
||||||
|
if (decryptionKeys !== undefined) {
|
||||||
|
parameters.push(...decryptionKeys);
|
||||||
|
}
|
||||||
|
const spawnedProcess = childProcess.spawn(processPath, parameters.map((value) => value.toString(), { cwd: '.' }));
|
||||||
|
|
||||||
|
spawnedProcess.stdout.pipe(outputStream);
|
||||||
|
//spawnedProcess.stdout.on('data', console.log);
|
||||||
|
spawnedProcess.stdout.on('end', resolve);
|
||||||
|
|
||||||
|
spawnedProcess.stderr.setEncoding('utf8');
|
||||||
|
spawnedProcess.stderr.on('data', reject);
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue