2021-12-11 15:20:28 +00:00
|
|
|
const paths = require('../paths');
|
|
|
|
const { join } = require('path');
|
|
|
|
const { copyFileSync, readdirSync } = require('original-fs'); // Use original-fs, not Electron's modified fs
|
|
|
|
|
|
|
|
module.exports = () => {
|
|
|
|
log('RetainAsar', 'Detected possible host update, retaining OpenAsar...');
|
|
|
|
|
|
|
|
const currentAsarPath = join(require.main.filename, '..');
|
|
|
|
|
|
|
|
const installDir = paths.getInstallPath();
|
|
|
|
|
|
|
|
const nextAppDir = readdirSync(installDir).reverse().find((x) => x.startsWith('app-1'));
|
2021-12-11 15:32:19 +00:00
|
|
|
const nextAppResources = join(installDir, nextAppDir, 'resources');
|
|
|
|
const nextAsarPath = join(nextAppResources, 'app.asar');
|
|
|
|
const backupAsarPath = join(nextAppResources, 'app.asar.backup');
|
2021-12-11 15:20:28 +00:00
|
|
|
|
2021-12-11 15:59:37 +00:00
|
|
|
if (nextAsarPath === currentAsarPath) return;
|
|
|
|
|
2021-12-11 15:20:28 +00:00
|
|
|
log('RetainAsar', `Paths:
|
|
|
|
Install Dir: ${installDir}
|
|
|
|
Next App Dir: ${nextAppDir}
|
|
|
|
Current Asar: ${currentAsarPath}
|
|
|
|
Next Asar: ${nextAsarPath}`);
|
|
|
|
|
2021-12-11 15:32:19 +00:00
|
|
|
copyFileSync(nextAsarPath, backupAsarPath);
|
2021-12-11 15:20:28 +00:00
|
|
|
copyFileSync(currentAsarPath, nextAsarPath);
|
|
|
|
|
|
|
|
log('RetainAsar', 'Completed');
|
|
|
|
};
|