From dba8850d143f1c784a708a72a4d12f92455ef031 Mon Sep 17 00:00:00 2001 From: sergeiown Date: Sat, 5 Oct 2024 16:04:28 +0300 Subject: [PATCH] Add timeouts to complete operations and fix messages --- messages.json | 16 ++++++++-------- modules/maintenance/integrityChecker.js | 6 +++--- modules/maintenance/updateHandler.js | 8 +++++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/messages.json b/messages.json index dab0fc0..01cc431 100644 --- a/messages.json +++ b/messages.json @@ -77,11 +77,11 @@ "msg_74": "VXNlciBkZWNsaW5lZCB0aGUgdXBkYXRl", "msg_75": "Tm8gQWxlcnQgU2VydmVyIHVwZGF0ZXMgYXJlIGF2YWlsYWJsZQ==", "msg_76": "RmFpbGVkIHRvIGRvd25sb2FkIGZpbGUuIFN0YXR1cyBjb2RlOg==", - "msg_77": "UmVkaXJlY3RpbmcgdG8=", - "msg_78": "RG93bmxvYWRlZCBuZXcgdmVyc2lvbg==", + "msg_77": "UmVkaXJlY3QgdG8gZG93bmxvYWQgVVJM", + "msg_78": "QSBuZXcgdmVyc2lvbiBoYXMgYmVlbiBkb3dubG9hZGVk", "msg_79": "RG93bmxvYWRlZCBmaWxlIGlzIGVtcHR5IG9yIGNvcnJ1cHRlZA==", - "msg_80": "VW56aXBwZWQgdXBkYXRl", - "msg_81": "UmVtb3ZlZCB6aXAgZmlsZQ==", + "msg_80": "TmV3IHZlcnNpb24gZXh0cmFjdGVkIGZyb20gdGhlIGFyY2hpdmU=", + "msg_81": "QXJjaGl2ZSBmaWxlIGlzIGRlbGV0ZWQ=", "msg_82": "RXJyb3IgcnVubmluZyBzZXR1cDo=", "msg_83": "RXJyb3IgZHVyaW5nIHVuemlwcGluZzo=", "msg_84": "RXJyb3IgZG93bmxvYWRpbmcgZmlsZTo=", @@ -169,11 +169,11 @@ "msg_74": "VXNlciBkZWNsaW5lZCB0aGUgdXBkYXRl", "msg_75": "Tm8gQWxlcnQgU2VydmVyIHVwZGF0ZXMgYXJlIGF2YWlsYWJsZQ==", "msg_76": "RmFpbGVkIHRvIGRvd25sb2FkIGZpbGUuIFN0YXR1cyBjb2RlOg==", - "msg_77": "UmVkaXJlY3RpbmcgdG8=", - "msg_78": "RG93bmxvYWRlZCBuZXcgdmVyc2lvbg==", + "msg_77": "UmVkaXJlY3QgdG8gZG93bmxvYWQgVVJM", + "msg_78": "QSBuZXcgdmVyc2lvbiBoYXMgYmVlbiBkb3dubG9hZGVk", "msg_79": "RG93bmxvYWRlZCBmaWxlIGlzIGVtcHR5IG9yIGNvcnJ1cHRlZA==", - "msg_80": "VW56aXBwZWQgdXBkYXRl", - "msg_81": "UmVtb3ZlZCB6aXAgZmlsZQ==", + "msg_80": "TmV3IHZlcnNpb24gZXh0cmFjdGVkIGZyb20gdGhlIGFyY2hpdmU=", + "msg_81": "QXJjaGl2ZSBmaWxlIGlzIGRlbGV0ZWQ=", "msg_82": "RXJyb3IgcnVubmluZyBzZXR1cDo=", "msg_83": "RXJyb3IgZHVyaW5nIHVuemlwcGluZzo=", "msg_84": "RXJyb3IgZG93bmxvYWRpbmcgZmlsZTo=", diff --git a/modules/maintenance/integrityChecker.js b/modules/maintenance/integrityChecker.js index 8e1628a..8f0bc63 100644 --- a/modules/maintenance/integrityChecker.js +++ b/modules/maintenance/integrityChecker.js @@ -30,11 +30,11 @@ const checkIntegrity = async () => { return; } - backupConfigFiles(); - - const logMessage = `Performing a restore from a repository`; + const logMessage = `Performing a restore from repository`; logEvent(logMessage); + backupConfigFiles(); + exec(`start cmd /c "${recoveryBatPath}"`, (execError) => { if (execError) { logEvent(execError.message); diff --git a/modules/maintenance/updateHandler.js b/modules/maintenance/updateHandler.js index 6463cb9..58d50b0 100644 --- a/modules/maintenance/updateHandler.js +++ b/modules/maintenance/updateHandler.js @@ -72,6 +72,10 @@ const downloadAndInstallUpdate = (latestVersion) => { fs.unlinkSync(zipPath); logEvent(messages.msg_81); + logEvent(messages.msg_71); + + backupConfigFiles(); + setTimeout(() => { exec(`start "" "${setupPath}"`, (err) => { if (err) { @@ -87,7 +91,7 @@ const downloadAndInstallUpdate = (latestVersion) => { }); }); } else if (response.statusCode === 302 && response.headers.location) { - logEvent(`${messages.msg_77} ${response.headers.location}`); + logEvent(messages.msg_77); downloadFile(response.headers.location); } else { logEvent(`${messages.msg_76} ${response.statusCode}`); @@ -134,8 +138,6 @@ const checkForUpdates = () => { if (error) { if (error.code === 6) { logEvent(messages.msg_73); - backupConfigFiles(); - logEvent(messages.msg_71); downloadAndInstallUpdate(latestVersion); } else if (error.code === 7) { logEvent(messages.msg_74);