Skip to content

Commit

Permalink
fix: Ensure appx and appimage use selfhost
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Dec 24, 2022
1 parent 6fc3ae8 commit 5acaa44
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xmcl-electron-app/main/utils/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class ElectronUpdater implements LauncherAppUpdater {

private async getUpdateFromSelfHost(): Promise<ReleaseInfo> {
const app = this.app
app.log('Try get update from selfhost')
const { allowPrerelease, locale } = app.serviceManager.get(BaseService).state
const url = `https://api.xmcl.app/latest?version=v${app.version}&prerelease=${allowPrerelease || false}`
const response = await request(url, {
Expand All @@ -126,6 +127,7 @@ export class ElectronUpdater implements LauncherAppUpdater {
const platformString = app.platform.name === 'windows' ? 'win' : app.platform.name === 'osx' ? 'mac' : 'linux'
const version = updateInfo.name.startsWith('v') ? updateInfo.name.substring(1) : updateInfo.name
updateInfo.incremental = updateInfo.files.some(f => f.name === `app-${version}-${platformString}.asar`)
app.log(`Got incremental=${updateInfo.incremental} update from selfhost`)

return updateInfo
}
Expand Down Expand Up @@ -208,6 +210,10 @@ export class ElectronUpdater implements LauncherAppUpdater {
checkUpdateTask(): Task<ReleaseInfo> {
return task('checkUpdate', async () => {
try {
if (this.app.env === 'appx') {
return this.getUpdateFromSelfHost()
}

let newUpdate = false
autoUpdater.once('update-available', () => {
this.logger.log('Update available and set status to pending')
Expand Down

0 comments on commit 5acaa44

Please sign in to comment.