Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions updater/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async function downloadFullRelease(release) {
mainWindow.webContents.send('text', 'Downloading Update');
const downloadPath =
process.platform === 'win32'
? './update.zip'
? path.join(__dirname, 'update.zip')
: './update/OpenGameInstaller.AppImage';
if (process.platform === 'linux') {
fs.mkdirSync('./update', { recursive: true });
Expand All @@ -452,16 +452,17 @@ async function downloadFullRelease(release) {
mainWindow.webContents.send('text', 'Download Complete');

if (process.platform === 'win32') {
persistSourceArtifact(assetWithPortable.name, './update.zip');
const zipPath = path.join(__dirname, 'update.zip');
persistSourceArtifact(assetWithPortable.name, zipPath);
mainWindow.webContents.send('text', 'Extracting Update');
await unzip(`./update.zip`, localCache);
await unzip(zipPath, localCache);
mainWindow.webContents.send('text', 'Copying Update Files');
copyCacheToUpdate(localCache);
fs.copyFileSync(
'./update.zip',
zipPath,
path.join(localCache, assetWithPortable.name)
);
fs.unlinkSync('./update.zip');
fs.unlinkSync(zipPath);
} else {
const item = path.join(__dirname, 'update', 'OpenGameInstaller.AppImage');
fs.copyFileSync(item, path.join(localCache, 'OpenGameInstaller.AppImage'));
Expand Down Expand Up @@ -605,7 +606,24 @@ async function applyBlockmapPatch(
`Short read from source artifact at ${matched.offset}: expected ${size}, got ${bytesRead}`
);
}
fs.writeSync(outFd, buffer, 0, size, writeOffset);
const expectedChecksum = newFile.checksums[i];
const digestBytes = createHash('sha256').update(buffer).digest();
const actualBase64 = digestBytes.toString('base64');
const actualHex = digestBytes.toString('hex');
const normalizedExpected =
typeof expectedChecksum === 'string'
? expectedChecksum.replace(/=+$/, '')
: '';
const normalizedBase64 = actualBase64.replace(/=+$/, '');
if (
expectedChecksum !== actualBase64 &&
expectedChecksum !== actualHex &&
normalizedExpected !== normalizedBase64
) {
misses.push({ offset: writeOffset, size });
} else {
fs.writeSync(outFd, buffer, 0, size, writeOffset);
}
} else {
misses.push({ offset: writeOffset, size });
}
Expand Down