patcher update, no more hardcoded urls, launch fixes
This commit is contained in:
62
main.js
62
main.js
@@ -3,15 +3,6 @@ const { app, BrowserWindow, Menu, ipcMain, dialog, shell } = require(
|
||||
"electron",
|
||||
);
|
||||
|
||||
/* const unhandled = require("electron-unhandled");
|
||||
unhandled({
|
||||
logger: console.error,
|
||||
showDialog: true,
|
||||
reportButton: () => {
|
||||
shell.openExternal("https://ez-pp.farm/discord");
|
||||
},
|
||||
}); */
|
||||
|
||||
const path = require("path");
|
||||
const serve = require("electron-serve");
|
||||
const loadURL = serve({ directory: "public" });
|
||||
@@ -27,15 +18,13 @@ const {
|
||||
downloadUpdateFiles,
|
||||
getUserConfig,
|
||||
runOsuWithDevServer,
|
||||
getPatcherUpdates,
|
||||
downloadPatcherUpdates,
|
||||
getUIFiles,
|
||||
downloadUIFiles,
|
||||
replaceUIFile,
|
||||
replaceUIFiles,
|
||||
findOsuInstallation,
|
||||
updateOsuConfigHashes,
|
||||
runOsuUpdater,
|
||||
gamemodes,
|
||||
getEZPPLauncherUpdateFiles,
|
||||
downloadEZPPLauncherUpdateFiles,
|
||||
} = require("./electron/osuUtil");
|
||||
const { formatBytes } = require("./electron/formattingUtil");
|
||||
const windowName = require("get-window-by-name");
|
||||
@@ -98,7 +87,8 @@ function startOsuStatus() {
|
||||
const patcherExecuteable = path.join(
|
||||
userOsuPath,
|
||||
"EZPPLauncher",
|
||||
"patcher.exe",
|
||||
"patcher",
|
||||
"osu!.patcher.exe",
|
||||
);
|
||||
if (fs.existsSync(patcherExecuteable)) {
|
||||
runFileDetached(userOsuPath, patcherExecuteable);
|
||||
@@ -414,6 +404,7 @@ function registerIPCPipes() {
|
||||
type: "error",
|
||||
message: "osu! path not set!",
|
||||
});
|
||||
mainWindow.webContents.send("ezpplauncher:open-settings");
|
||||
return;
|
||||
}
|
||||
if (!(await isValidOsuFolder(osuPath))) {
|
||||
@@ -430,38 +421,7 @@ function registerIPCPipes() {
|
||||
await new Promise((res) => setTimeout(res, 1000));
|
||||
const releaseStream = await getGlobalConfig(osuPath).get("_ReleaseStream");
|
||||
const latestFiles = await getUpdateFiles(releaseStream);
|
||||
const uiFiles = await getUIFiles(osuPath);
|
||||
const updateFiles = await getFilesThatNeedUpdate(osuPath, latestFiles);
|
||||
if (uiFiles.length > 0) {
|
||||
const uiDownloader = downloadUIFiles(osuPath, uiFiles);
|
||||
let errored = false;
|
||||
uiDownloader.eventEmitter.on("error", (data) => {
|
||||
const filename = data.fileName;
|
||||
errored = true;
|
||||
mainWindow.webContents.send("ezpplauncher:alert", {
|
||||
type: "error",
|
||||
message:
|
||||
`Failed to download/replace ${filename}!\nMaybe try to restart EZPPLauncher.`,
|
||||
});
|
||||
});
|
||||
uiDownloader.eventEmitter.on("data", (data) => {
|
||||
mainWindow.webContents.send("ezpplauncher:launchprogress", {
|
||||
progress: Math.ceil(data.progress),
|
||||
});
|
||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)
|
||||
})...`,
|
||||
});
|
||||
});
|
||||
await uiDownloader.startDownload();
|
||||
mainWindow.webContents.send("ezpplauncher:launchprogress", {
|
||||
progress: -1,
|
||||
});
|
||||
if (errored) {
|
||||
mainWindow.webContents.send("ezpplauncher:launchabort");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (updateFiles.length > 0) {
|
||||
const updateDownloader = downloadUpdateFiles(osuPath, updateFiles);
|
||||
let errored = false;
|
||||
@@ -507,9 +467,9 @@ function registerIPCPipes() {
|
||||
status: "Looking for patcher updates...",
|
||||
});
|
||||
await new Promise((res) => setTimeout(res, 1000));
|
||||
const patchFiles = await getPatcherUpdates(osuPath);
|
||||
const patchFiles = await getEZPPLauncherUpdateFiles(osuPath);
|
||||
if (patchFiles.length > 0) {
|
||||
const patcherDownloader = downloadPatcherUpdates(osuPath, patchFiles);
|
||||
const patcherDownloader = await downloadEZPPLauncherUpdateFiles(osuPath, patchFiles);
|
||||
let errored = false;
|
||||
patcherDownloader.eventEmitter.on("error", (data) => {
|
||||
const filename = data.fileName;
|
||||
@@ -580,14 +540,14 @@ function registerIPCPipes() {
|
||||
});
|
||||
|
||||
await updateOsuConfigHashes(osuPath);
|
||||
await replaceUIFile(osuPath, false);
|
||||
await replaceUIFiles(osuPath, false);
|
||||
|
||||
const forceUpdateFiles = [
|
||||
".require_update",
|
||||
"help.txt",
|
||||
"_pending",
|
||||
];
|
||||
//TODO: needs testing
|
||||
|
||||
try {
|
||||
for (const updateFileName of forceUpdateFiles) {
|
||||
const updateFile = path.join(osuPath, updateFileName);
|
||||
@@ -635,7 +595,7 @@ function registerIPCPipes() {
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
await replaceUIFile(osuPath, true);
|
||||
await replaceUIFiles(osuPath, true);
|
||||
mainWindow.webContents.send("ezpplauncher:launchabort");
|
||||
osuLoaded = false;
|
||||
}, 5000);
|
||||
|
Reference in New Issue
Block a user