get updated files from osu

This commit is contained in:
HorizonCode 2022-10-16 18:52:34 +02:00
parent 830b1099ac
commit 2bf98db729
2 changed files with 15 additions and 6 deletions

12
app.js
View File

@ -22,12 +22,18 @@ const run = () => {
mainWindow = createWindow(); mainWindow = createWindow();
mainWindow.on('show', async () => { mainWindow.on('show', async () => {
const osuPath = await config.get("osuPath", ""); const osuPath = await config.get("osuPath", "");
if(fs.existsSync(osuPath)){ if (fs.existsSync(osuPath)) {
tempOsuPath = osuPath; tempOsuPath = osuPath;
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath); const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
console.log(osuConfig);
const lastVersion = await osuConfig.get("LastVersion"); 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 //Do update check
} }
}) })

View File

@ -1,6 +1,8 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const axios = require('axios').default;
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
const osuEntities = [ const osuEntities = [
'avcodec-51.dll', 'avcodec-51.dll',
'avformat-52.dll', 'avformat-52.dll',
@ -75,8 +77,9 @@ async function getLatestConfig(osuPath) {
return configFileInfo; return configFileInfo;
} }
async function checkForUpdate(path) { async function getUpdateFiles(releaseStream) {
const releaseData = await axios.get(checkUpdateURL + releaseStream, {});
return releaseData.data;
} }
module.exports = { isValidOsuFolder, getLatestConfig } module.exports = { isValidOsuFolder, getLatestConfig, getUpdateFiles }