move updater to fsync so its fully committed to disk before relaunching (#565)

This commit is contained in:
creations 2025-12-15 19:08:15 -05:00 • committed by GitHub
parent aae50c46f7
commit dfab53d188
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,7 +20,7 @@ import { fetchBuffer, fetchJson } from "@main/utils/http";
import { IpcEvents } from "@shared/IpcEvents";
import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
import { ipcMain } from "electron";
import { writeFileSync as originalWriteFileSync } from "original-fs";
import { closeSync, fsyncSync, openSync, writeFileSync as originalWriteFileSync } from "original-fs";
import gitHash from "~git-hash";
import gitRemote from "~git-remote";
@ -74,6 +74,10 @@ async function applyUpdates() {
const data = await fetchBuffer(PendingUpdate);
originalWriteFileSync(__dirname, data);
const fd = openSync(__dirname, "r");
fsyncSync(fd);
closeSync(fd);
PendingUpdate = null;
return true;