From 2bf98db729a7f327cff21dac4a03ab43bc739c96 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Sun, 16 Oct 2022 18:52:34 +0200 Subject: [PATCH] get updated files from osu --- app.js | 12 +++++++++--- osuUtil.js | 9 ++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 53f839d..fbe4334 100644 --- a/app.js +++ b/app.js @@ -22,12 +22,18 @@ const run = () => { mainWindow = createWindow(); mainWindow.on('show', async () => { const osuPath = await config.get("osuPath", ""); - if(fs.existsSync(osuPath)){ + if (fs.existsSync(osuPath)) { tempOsuPath = osuPath; const osuConfig = await osuUtil.getLatestConfig(tempOsuPath); - console.log(osuConfig); const lastVersion = await osuConfig.get("LastVersion"); - console.log(lastVersion); + let releaseStream = "stable40"; + if (lastVersion.endsWith("cuttingedge")) + releaseStream = "cuttingedge" + else if (lastVersion.endsWith("beta")) + releaseStream = "beta"; + + const releaseFiles = await osuUtil.getUpdateFiles(releaseStream); + console.log(releaseFiles); //Do update check } }) diff --git a/osuUtil.js b/osuUtil.js index 0fa956f..74efe99 100644 --- a/osuUtil.js +++ b/osuUtil.js @@ -1,6 +1,8 @@ const fs = require('fs'); const path = require('path'); +const axios = require('axios').default; +const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream="; const osuEntities = [ 'avcodec-51.dll', 'avformat-52.dll', @@ -75,8 +77,9 @@ async function getLatestConfig(osuPath) { return configFileInfo; } -async function checkForUpdate(path) { - +async function getUpdateFiles(releaseStream) { + const releaseData = await axios.get(checkUpdateURL + releaseStream, {}); + return releaseData.data; } -module.exports = { isValidOsuFolder, getLatestConfig } \ No newline at end of file +module.exports = { isValidOsuFolder, getLatestConfig, getUpdateFiles } \ No newline at end of file