From 47f86501b8c4d3ff32cdbccfc5a0bff12b794df9 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Fri, 2 Jun 2023 14:34:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 5 ----- osuUtil.js | 29 ++++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index 7e9296d..8325c5f 100644 --- a/app.js +++ b/app.js @@ -120,7 +120,6 @@ const run = () => { rpc.connect(); - let mainWindow; let tray = null app.whenReady().then(async () => { @@ -195,18 +194,15 @@ const run = () => { } else linuxWMCtrlFound = true; } else { const osuFolder = await config.get("osuPath"); - console.log(osuFolder, !osuFolder || osuFolder == ""); if (!osuFolder || osuFolder == "") { const foundFolder = await osuUtil.findOsuInstallation(); if (foundFolder && osuUtil.isValidOsuFolder(foundFolder)) { mainWindow.webContents.send('alert_message', foundFolder); } - console.log("osu! Installation located at: ", foundFolder); } } }); ipcMain.on("alert_response", async (event, path) => { - console.log("yes"); await config.set("osuPath", path); }) app.on('activate', function () { @@ -358,7 +354,6 @@ async function tryLogin(window) { async function doUpdateCheck(window) { const osuPath = await config.get("osuPath"); - console.log("osuPath:", osuPath); if (!osuPath || osuPath.trim == "") { window.webContents.send('status_update', { type: "missing-folder" diff --git a/osuUtil.js b/osuUtil.js index f73673a..48bc971 100644 --- a/osuUtil.js +++ b/osuUtil.js @@ -8,7 +8,8 @@ const { EventEmitter } = require('events'); const { DownloaderHelper } = require('node-downloader-helper'); const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream="; -const customUIDLLPath = ""; +const customUIDLLPath = "https://ez-pp.farm/assets/ezpp!ui.dll"; +const customUIDLLHash = "https://ez-pp.farm/assets/ezpp!ui.md5"; const customUIDLLName = "ezpp!ui.dll"; const ignoredOsuEntities = [ 'osu!auth.dll', @@ -85,6 +86,11 @@ async function getUpdateFiles(releaseStream) { return releaseData.data; } +async function getEZPPUIMD5() { + const releaseData = await axios.get(customUIDLLHash, {}); + return releaseData.data; +} + async function filesThatNeedUpdate(osuPath, updateFiles) { const filesToDownload = []; for (const updatedFile of updateFiles) { @@ -111,6 +117,24 @@ async function filesThatNeedUpdate(osuPath, updateFiles) { }); } } + + const ezppUI = path.join(osuPath, customUIDLLName); + if (fs.existsSync(ezppUI)) { + const latestMd5Hash = await getEZPPUIMD5(); + const binaryUIContents = await fs.promises.readFile(ezppUI); + const existingUIMD5 = crypto.createHash("md5").update(binaryUIContents).digest("hex"); + if (existingUIMD5 != latestMd5Hash) { + filesToDownload.push({ + fileName: "ezpp!ui.dll", + fileURL: customUIDLLPath + }) + } + } else + filesToDownload.push({ + fileName: "ezpp!ui.dll", + fileURL: customUIDLLPath + }) + return filesToDownload; } @@ -119,7 +143,6 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) { let completedIndex = 0; filesToUpdate.forEach(async (fileToUpdate) => { const filePath = path.join(osuPath, fileToUpdate.fileName); - console.log(filePath); if (await fu.existsAsync(filePath)) await fs.promises.rm(filePath); @@ -240,5 +263,5 @@ async function replaceUI(folder, isStart) { module.exports = { isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate, downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue, - findOsuInstallation, replaceUI, updateOsuCfg + findOsuInstallation, replaceUI, updateOsuCfg, getEZPPUIMD5 } \ No newline at end of file