mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-09 06:33:03 -04:00
Migrate
This commit is contained in:
parent
957c87d939
commit
047cc5da69
1 changed files with 36 additions and 1 deletions
|
@ -16,11 +16,17 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { isLegacyNonAsarVencord } from "@main/patcher";
|
||||||
import { get } from "@main/utils/simpleGet";
|
import { get } from "@main/utils/simpleGet";
|
||||||
import { IpcEvents } from "@shared/IpcEvents";
|
import { IpcEvents } from "@shared/IpcEvents";
|
||||||
import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
|
import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
|
||||||
import { ipcMain } from "electron";
|
import { app, dialog, ipcMain } from "electron";
|
||||||
import { writeFile } from "fs/promises";
|
import { writeFile } from "fs/promises";
|
||||||
|
import {
|
||||||
|
existsSync,
|
||||||
|
unlinkSync,
|
||||||
|
writeFileSync,
|
||||||
|
} from "original-fs";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
import gitHash from "~git-hash";
|
import gitHash from "~git-hash";
|
||||||
|
@ -87,6 +93,35 @@ async function applyUpdates() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function migrateAsarToLegacy() {
|
||||||
|
try {
|
||||||
|
const isFlatpak = process.platform === "linux" && !!process.env.FLATPAK_ID;
|
||||||
|
if (isFlatpak) throw "Flatpak Discord can't automatically be migrated.";
|
||||||
|
|
||||||
|
const asarPath = join(__dirname, "../equicord.asar");
|
||||||
|
if (existsSync(asarPath)) {
|
||||||
|
unlinkSync(asarPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFileSync(__filename, "// Shim for legacy Equicord\n\nrequire(\"./index.js\");");
|
||||||
|
|
||||||
|
app.relaunch();
|
||||||
|
app.exit();
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to migrate to legacy", e);
|
||||||
|
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
dialog.showErrorBox(
|
||||||
|
"Migration Error",
|
||||||
|
"Failed to migrate back to the legacy version. Please reinstall using the Equicord Installer."
|
||||||
|
);
|
||||||
|
app.exit(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLegacyNonAsarVencord) migrateAsarToLegacy();
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.GET_REPO, serializeErrors(() => `https://github.com/${gitRemote}`));
|
ipcMain.handle(IpcEvents.GET_REPO, serializeErrors(() => `https://github.com/${gitRemote}`));
|
||||||
ipcMain.handle(IpcEvents.GET_UPDATES, serializeErrors(calculateGitChanges));
|
ipcMain.handle(IpcEvents.GET_UPDATES, serializeErrors(calculateGitChanges));
|
||||||
ipcMain.handle(IpcEvents.UPDATE, serializeErrors(fetchUpdates));
|
ipcMain.handle(IpcEvents.UPDATE, serializeErrors(fetchUpdates));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue