4
0
mirror of https://github.com/AltarikMC/Launcher synced 2024-11-22 06:19:50 +01:00

Fix updater (well I think too)

This commit is contained in:
Quentin Legot 2022-10-13 21:55:09 +02:00
parent f9142e9094
commit 7d2eeb9e69

View File

@ -56,27 +56,33 @@ class Updater {
win.loadFile('src/client/login.html') win.loadFile('src/client/login.html')
}) })
} else { } else {
fetch(feed).then(response => { this.searchUpdateLinux(win, showNotification)
if(response.status === 200) {
response.json().then(json => {
win.webContents.send("please-download-update", { url: json.url} )
})
} else {
if(response.status === 204) {
this.logger.info("update not available")
win.loadFile('src/client/login.html')
} else {
this.displayError(win, showNotification, "Server return " + response.status + " http code")
}
}
}).catch(err => {
this.displayError(win, showNotification, err)
})
} }
} }
searchUpdateLinux(win, showNotification) {
const url = 'https://api.github.com/repos/AltarikMc/Launcher/releases/latest'
fetch(url).then(response => {
if(response.status === 200) {
response.json().then(json => {
if(json.tag_name !== pkg.version) {
let asset = json.assets.filter(el => el.browser_download_url.inludes(".zip"))
if(asset.length ===1) {
let downloadUrl = asset[0].browser_download_url
win.webContents.send("please-download-update", { url: downloadUrl} )
} else {
this.displayError(win, showNotification, "Can't find right asset in last update")
}
}
}).catch(err => this.displayError(win, showNotification, err)
)
} else {
this.displayError(win, showNotification, "Server unavailable")
}
}).catch(err => this.displayError(win, showNotification, err))
}
displayError(win, showNotification, errorMessage) { displayError(win, showNotification, errorMessage) {
this.logger.error('There was a problem updating the application') this.logger.error('There was a problem updating the application')
this.logger.error(errorMessage) this.logger.error(errorMessage)