aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorCanadaHonk <19228318+CanadaHonk@users.noreply.github.com>2023-08-18 23:54:35 +0100
committerGitHub <noreply@github.com>2023-08-19 00:54:35 +0200
commitd582e61ec30713a8e540ca3d0d02160406a1d0d9 (patch)
tree1e96092e3a34de1cfe79881d6dfe31137e6f258f /src/main
parentccd2ce8bafad99080b78caa9a7abe57ec2d153f2 (diff)
downloadVencord-d582e61ec30713a8e540ca3d0d02160406a1d0d9.tar.gz
Vencord-d582e61ec30713a8e540ca3d0d02160406a1d0d9.tar.bz2
Vencord-d582e61ec30713a8e540ca3d0d02160406a1d0d9.zip
Fix patching Win32 updater with OpenAsar (#1667)
This is more generic rewrite allowing for more paths to be added in the future for whatever reason (like a rename in future Discord versions). (The "OpenAsar" code previously was completely wrong)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/patchWin32Updater.ts34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/main/patchWin32Updater.ts b/src/main/patchWin32Updater.ts
index e08e37d..6cf1a43 100644
--- a/src/main/patchWin32Updater.ts
+++ b/src/main/patchWin32Updater.ts
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import { app, autoUpdater } from "electron";
+import { app } from "electron";
import { existsSync, mkdirSync, readdirSync, renameSync, statSync, writeFileSync } from "fs";
import { basename, dirname, join } from "path";
@@ -80,20 +80,22 @@ function patchLatest() {
// Windows Host Updates install to a new folder app-{HOST_VERSION}, so we
// need to reinject
function patchUpdater() {
- try {
- const autoStartScript = join(require.main!.filename, "..", "autoStart", "win32.js");
- const { update } = require(autoStartScript);
-
- require.cache[autoStartScript]!.exports.update = function () {
- update.apply(this, arguments);
- patchLatest();
- };
- } catch {
- // OpenAsar uses electrons autoUpdater on Windows
- const { quitAndInstall } = autoUpdater;
- autoUpdater.quitAndInstall = function () {
- patchLatest();
- quitAndInstall.call(this);
- };
+ // Array of autoStart paths to try
+ const autoStartPaths = [
+ join(require.main!.filename, "..", "autoStart", "win32.js"), // Vanilla
+ join(require.main!.filename, "..", "autoStart.js") // OpenAsar
+ ];
+
+ for (const path of autoStartPaths) {
+ try {
+ const { update } = require(path);
+
+ require.cache[path]!.exports.update = function () {
+ update.apply(this, arguments);
+ patchLatest();
+ };
+ } catch {
+ // Ignore as non-critical
+ }
}
}