[AsarUpdate] Disable update prompt by default, rewrite to be async
This commit is contained in:
parent
b2413f595a
commit
f36174e55b
11
README.md
11
README.md
|
@ -27,13 +27,18 @@ OpenAsar is highly stable, but still likely has a few possible minor issues. Cra
|
|||
<!-- **If using Linux it is highly recommended to disable write protection** (needing root to overwrite files) for your Discord install if you have it enabled. It is not much of a security defecit as Windows has no write protection as well. This enables updating the asar and potentially host updating further on. -->
|
||||
|
||||
## Config
|
||||
You can configure OpenAsar via `settings.json` (found in your Discord app data / user data), under a `openasar` object. Keep in mind most options are defaults for good reason. The avaliable options are:
|
||||
You can configure OpenAsar via `settings.json` (found in your Discord app data / user data), under a `openasar` object. Keep in mind most options are defaults for good reason.
|
||||
|
||||
### OpenAsar Options
|
||||
- `quickstart` (bool, default false) - whether to use Quickstart (experimental)
|
||||
- `themeSync` (bool, default true) - syncs your modded client's theme with splash theming
|
||||
- `autoupdate` (bool, default true) - whether to autoupdate OpenAsar after Discord startup
|
||||
- `multiInstance` (bool, default false) - whether to enable multi-instance
|
||||
- `ssoeAllowlist` (bool, default true) - whether to use safer custom method of opening external urls (true) or normal Discord's method (false)
|
||||
- `updatePrompt` (bool, default false) - whether to show update prompt after updating OpenAsar
|
||||
- `splashText` (bool, default true) - whether to show bottom right version info text in splash
|
||||
- `ssoeAllowlist` (bool, default true) - whether to use safer custom method of opening external urls (true) or normal Discord's method (false)
|
||||
|
||||
### Extra Discord Options
|
||||
- `multiInstance` (bool, default false) - whether to enable multi-instance
|
||||
- `skipStartupUpdateChecks` (bool, default false) - skips startup update checking (Linux-only)
|
||||
|
||||
An example of a settings.json with OpenAsar config:
|
||||
|
|
|
@ -15,7 +15,7 @@ const channel = 'nightly'; // Have prod, etc. once stable / 1.0
|
|||
|
||||
const getAsarHash = () => crypto.createHash('sha512').update(fs.readFileSync(asarPath)).digest('hex');
|
||||
|
||||
module.exports = () => { // (Try) update asar
|
||||
module.exports = async () => { // (Try) update asar
|
||||
log('AsarUpdate', 'Updating...');
|
||||
|
||||
if (!oaVersion.startsWith('nightly-')) {
|
||||
|
@ -28,6 +28,7 @@ module.exports = () => { // (Try) update asar
|
|||
const originalHash = getAsarHash();
|
||||
log('AsarUpdate', 'Original Hash:', originalHash);
|
||||
|
||||
const updateSuccess = await new Promise((res) => {
|
||||
const file = fs.createWriteStream(asarPath);
|
||||
|
||||
let writeError = false;
|
||||
|
@ -36,17 +37,29 @@ module.exports = () => { // (Try) update asar
|
|||
file.close();
|
||||
|
||||
writeError = true;
|
||||
res(false);
|
||||
});
|
||||
|
||||
log('AsarUpdate', 'Opened write stream to asar');
|
||||
|
||||
request(asarUrl, (_err, res) => {
|
||||
if (writeError) return;
|
||||
|
||||
log('AsarUpdate', 'Piping download response to stream');
|
||||
res.pipe(file);
|
||||
});
|
||||
|
||||
file.on('finish', async () => {
|
||||
file.on('finish', () => {
|
||||
file.close();
|
||||
res(true);
|
||||
});
|
||||
});
|
||||
|
||||
if (!updateSuccess) {
|
||||
log('AsarUpdate', 'Aborting rest of update due to update error');
|
||||
return;
|
||||
}
|
||||
|
||||
log('AsarUpdate', 'Completed download');
|
||||
|
||||
const newHash = getAsarHash();
|
||||
|
@ -57,7 +70,7 @@ Original Hash: ${originalHash}
|
|||
New Hash: ${newHash}
|
||||
Changed: ${changed}`);
|
||||
|
||||
if (changed) {
|
||||
if (changed && oaConfig.updatePrompt === true) {
|
||||
const { response } = await electron.dialog.showMessageBox(null, {
|
||||
message: 'Updated OpenAsar',
|
||||
detail: `Restart required to use new version.`,
|
||||
|
@ -74,9 +87,4 @@ Changed: ${changed}`);
|
|||
electron.app.exit();
|
||||
}
|
||||
}
|
||||
|
||||
if (writeError) {
|
||||
// Warn message?
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue