9 Commits

Author SHA1 Message Date
cd8f42327c remove logging 2024-04-23 09:56:45 +02:00
6881a0d1d5 pruning fixes 2024-04-23 09:56:22 +02:00
9f9804f161 small bugfixes 2024-04-23 09:38:11 +02:00
3bd1fb9edb fix assurance check 2024-04-23 08:57:21 +02:00
8a8856772e assurance check, that the launcher does not delete stuff directly in the osu folder 2024-04-23 08:55:00 +02:00
80343bd929 clean up unneeded files 2024-04-23 08:52:23 +02:00
9da481b991 bump version 2024-04-23 08:51:54 +02:00
70643c4287 update sweetalert 2, bump version 2024-04-23 08:51:47 +02:00
db03ed552f fix update dialog 2024-04-23 08:51:16 +02:00
7 changed files with 62 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
const appName = "EZPPLauncher"; const appName = "EZPPLauncher";
const appVersion = "2.1.5"; const appVersion = "2.1.6";
module.exports = { appName, appVersion }; module.exports = { appName, appVersion };

View File

@@ -264,13 +264,37 @@ async function getEZPPLauncherUpdateFiles(osuPath) {
filesToDownload.push(updateFile); filesToDownload.push(updateFile);
} }
} }
return filesToDownload; return [filesToDownload, updateFiles];
} }
async function downloadEZPPLauncherUpdateFiles(osuPath, updateFiles) { async function downloadEZPPLauncherUpdateFiles(osuPath, updateFiles, allFiles) {
const eventEmitter = new EventEmitter(); const eventEmitter = new EventEmitter();
const startDownload = async () => { const startDownload = async () => {
//NOTE: delete files that are not in the updateFiles array
const foldersToPrune = allFiles.map(file => path.dirname(path.join(osuPath, ...file.folder.split("/"), file.name))).filter((folder, index, self) => self.indexOf(folder) === index);
for (const pruneFolder of foldersToPrune) {
//NOTE: check if the folder is not the osu root folder.
if (path.basename(pruneFolder) == "osu!")
continue;
if (fs.existsSync(pruneFolder)) {
for (const files of await fs.promises.readdir(pruneFolder)) {
const filePath = path.join(pruneFolder, files);
const validFolder = allFiles.find(file => path.dirname(filePath).endsWith(file.folder));
if (!validFolder) {
if (allFiles.find(file => file.name == path.basename(filePath)) === undefined) {
eventEmitter.emit("data", {
fileName: path.basename(filePath),
});
try {
await fs.promises.rm(filePath, { recursive: true, force: true });
} catch { }
}
}
}
}
}
for (const updateFile of updateFiles) { for (const updateFile of updateFiles) {
try { try {
const filePath = path.join( const filePath = path.join(

37
main.js
View File

@@ -430,6 +430,12 @@ function registerIPCPipes() {
return config.all(); return config.all();
}); });
ipcMain.handle("ezpplauncher:checkUpdate", async (e) => {
const updateInfo = await updateAvailable();
if (updateInfo.update)
mainWindow.webContents.send("ezpplauncher:update", updateInfo.release);
});
ipcMain.handle("ezpplauncher:exitAndUpdate", async (e) => { ipcMain.handle("ezpplauncher:exitAndUpdate", async (e) => {
await shell.openExternal(releasesUrl); await shell.openExternal(releasesUrl);
app.exit(); app.exit();
@@ -523,9 +529,8 @@ function registerIPCPipes() {
progress: Math.ceil(data.progress), progress: Math.ceil(data.progress),
}); });
mainWindow.webContents.send("ezpplauncher:launchstatus", { mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)
formatBytes(data.total) })...`,
})...`,
}); });
}); });
await updateDownloader.startDownload(); await updateDownloader.startDownload();
@@ -552,12 +557,13 @@ function registerIPCPipes() {
status: "Looking for patcher updates...", status: "Looking for patcher updates...",
}); });
await new Promise((res) => setTimeout(res, 1000)); await new Promise((res) => setTimeout(res, 1000));
const patchFiles = await getEZPPLauncherUpdateFiles(osuPath); const [patchFiles, allUpdateFiles] = await getEZPPLauncherUpdateFiles(osuPath);
if (patchFiles.length > 0) { if (patchFiles.length > 0) {
logger.log("EZPPLauncher updates found."); logger.log("EZPPLauncher updates found.");
const patcherDownloader = await downloadEZPPLauncherUpdateFiles( const patcherDownloader = await downloadEZPPLauncherUpdateFiles(
osuPath, osuPath,
patchFiles, patchFiles,
allUpdateFiles
); );
let errored = false; let errored = false;
patcherDownloader.eventEmitter.on("error", (data) => { patcherDownloader.eventEmitter.on("error", (data) => {
@@ -578,9 +584,17 @@ function registerIPCPipes() {
progress: Math.ceil(data.progress), progress: Math.ceil(data.progress),
}); });
mainWindow.webContents.send("ezpplauncher:launchstatus", { mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: `Downloading ${data.fileName}(${ status: `Downloading ${data.fileName}(${formatBytes(data.loaded)
formatBytes(data.loaded) }/${formatBytes(data.total)})...`,
}/${formatBytes(data.total)})...`, });
});
patcherDownloader.eventEmitter.on("delete", (data) => {
logger.log(`Deleting ${data.fileName}!`);
mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: -1,
});
mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: `Deleting ${data.fileName}...`,
}); });
}); });
await patcherDownloader.startDownload(); await patcherDownloader.startDownload();
@@ -660,7 +674,7 @@ function registerIPCPipes() {
if (fs.existsSync(updateFile)) { if (fs.existsSync(updateFile)) {
await fs.promises.rm(updateFile, { await fs.promises.rm(updateFile, {
force: true, force: true,
recursive: (await fs.promises.lstat(updateFile)).isDirectory, recursive: (await fs.promises.lstat(updateFile)).isDirectory(),
}); });
} }
} }
@@ -714,8 +728,7 @@ function registerIPCPipes() {
const osuGameplayFile = path.join(osuPath, "osu!gameplay.dll"); const osuGameplayFile = path.join(osuPath, "osu!gameplay.dll");
if (isWritable(osuUIFile) && isWritable(osuGameplayFile)) { if (isWritable(osuUIFile) && isWritable(osuGameplayFile)) {
logger.log( logger.log(
`Cleanup complete, took ${ `Cleanup complete, took ${((performance.now() - timeStart) / 1000).toFixed(3)
((performance.now() - timeStart) / 1000).toFixed(3)
} seconds.`, } seconds.`,
); );
clearInterval(cleanup); clearInterval(cleanup);
@@ -819,10 +832,6 @@ function createWindow() {
// Emitted when the window is ready to be shown // Emitted when the window is ready to be shown
// This helps in showing the window gracefully. // This helps in showing the window gracefully.
mainWindow.once("ready-to-show", async () => { mainWindow.once("ready-to-show", async () => {
const updateInfo = await updateAvailable();
if (updateInfo.update) {
mainWindow.webContents.send("ezpplauncher:update", updateInfo.release);
}
mainWindow.show(); mainWindow.show();
mainWindow.focus(); mainWindow.focus();
}); });

8
package-lock.json generated
View File

@@ -24,7 +24,7 @@
"regedit-rs": "^1.0.2", "regedit-rs": "^1.0.2",
"semver": "^7.5.4", "semver": "^7.5.4",
"svelte-french-toast": "^1.2.0", "svelte-french-toast": "^1.2.0",
"sweetalert2": "^11.10.3", "sweetalert2": "^11.10.8",
"systeminformation": "^5.21.22" "systeminformation": "^5.21.22"
}, },
"devDependencies": { "devDependencies": {
@@ -8533,9 +8533,9 @@
"dev": true "dev": true
}, },
"node_modules/sweetalert2": { "node_modules/sweetalert2": {
"version": "11.10.7", "version": "11.10.8",
"resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.10.7.tgz", "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.10.8.tgz",
"integrity": "sha512-5Jlzrmaitay6KzU+2+LhYu9q+L4v/dZ8oZyEDH14ep0C/QilCnFLHmqAyD/Lhq/lm5DiwsOs6Tr58iv8k3wyGg==", "integrity": "sha512-oAkYROBfXBY+4sVbQEIcN+ZxAx69lsmz5WEBwdEpyS4m59vOBNlRU5/fJpAI1MVfiDwFZiGwVzB/KBpOyfLNtg==",
"funding": { "funding": {
"type": "individual", "type": "individual",
"url": "https://github.com/sponsors/limonte" "url": "https://github.com/sponsors/limonte"

View File

@@ -1,6 +1,6 @@
{ {
"name": "ezpplauncher-next", "name": "ezpplauncher-next",
"version": "2.1.5", "version": "2.1.6",
"description": "EZPPLauncher rewritten with Svelte.", "description": "EZPPLauncher rewritten with Svelte.",
"private": false, "private": false,
"license": "MIT", "license": "MIT",
@@ -51,7 +51,7 @@
"regedit-rs": "^1.0.2", "regedit-rs": "^1.0.2",
"semver": "^7.5.4", "semver": "^7.5.4",
"svelte-french-toast": "^1.2.0", "svelte-french-toast": "^1.2.0",
"sweetalert2": "^11.10.3", "sweetalert2": "^11.10.8",
"systeminformation": "^5.21.22" "systeminformation": "^5.21.22"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -82,6 +82,10 @@ window.addEventListener("settings-set", async (e) => {
await ipcRenderer.invoke("ezpplauncher:settings-set", e.detail); await ipcRenderer.invoke("ezpplauncher:settings-set", e.detail);
}); });
window.addEventListener("updateCheck", async () => {
await ipcRenderer.invoke("ezpplauncher:checkUpdate");
})
window.addEventListener("updateExit", async () => { window.addEventListener("updateExit", async () => {
await ipcRenderer.invoke("ezpplauncher:exitAndUpdate"); await ipcRenderer.invoke("ezpplauncher:exitAndUpdate");
}); });

View File

@@ -66,6 +66,8 @@
window.dispatchEvent(new CustomEvent("updateExit")); window.dispatchEvent(new CustomEvent("updateExit"));
}); });
window.dispatchEvent(new CustomEvent("updateCheck"));
window.addEventListener("open-settings", (e) => { window.addEventListener("open-settings", (e) => {
currentPage.set(Page.Settings); currentPage.set(Page.Settings);
}); });