Skip to content

Commit

Permalink
fix: Auto update does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Nov 7, 2023
1 parent 23fbec2 commit 5eb8a7b
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 194 deletions.
25 changes: 23 additions & 2 deletions xmcl-electron-app/main/utils/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { DownloadAppInstallerTask } from './appinstaller'
import { checksum } from './fs'
import { GFW } from '@xmcl/runtime/lib/entities/gfw'
import { ensureElevateExe } from './elevate'
import { shell } from 'electron'

/**
* Only download asar file update.
Expand Down Expand Up @@ -69,6 +70,21 @@ export class DownloadAsarUpdateTask extends DownloadTask {
}
}

export class HintUserDownloadTask extends BaseTask<void> {
protected async runTask(): Promise<void> {
shell.openExternal('https://xmcl.app')
}

protected async cancelTask(): Promise<void> {
}

protected async pauseTask(): Promise<void> {
}

protected async resumeTask(): Promise<void> {
}
}

/**
* Download the full update. This size can be larger as it carry the whole electron thing...
*/
Expand Down Expand Up @@ -142,7 +158,7 @@ export class ElectronUpdater implements LauncherAppUpdater {
}

private async quitAndInstallAsar() {
const appAsarPath = dirname(__dirname)
const appAsarPath = join(dirname(__dirname), 'app.asar')
const updateAsarPath = join(this.app.appDataPath, 'pending_update')

this.logger.log(`Install asar on ${this.app.platform.os} ${appAsarPath}`)
Expand Down Expand Up @@ -271,14 +287,19 @@ export class ElectronUpdater implements LauncherAppUpdater {

downloadUpdateTask(updateInfo: ReleaseInfo): Task<void> {
if (this.app.env === 'appx') {
this.logger.log('Download appx from selfhost')
return new DownloadAppInstallerTask(this.app)
}
if (updateInfo.incremental && this.app.env === 'raw') {
this.logger.log('Download asar from selfhost')
const updatePath = join(this.app.appDataPath, 'pending_update')
return new DownloadAsarUpdateTask(updatePath, updateInfo.name)
.map(() => undefined)
}
return new DownloadFullUpdateTask()
if (updateInfo.useAutoUpdater) {
return new DownloadFullUpdateTask()
}
return new HintUserDownloadTask()
}

async installUpdateAndQuit(updateInfo: ReleaseInfo): Promise<void> {
Expand Down
3 changes: 3 additions & 0 deletions xmcl-keystone-ui/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,9 @@ setting:
linuxTitlebar: Native title bar
linuxTitlebarDescription: Use native linux title bar for launcher
location: Store Location
maunalUpdateHint: >-
The version cannot be auto-updated. Please redownload the launcher from the
website!
maxSockets: Per Host
maxSocketsDescription: >-
Limit the maximum number of sockets to allow per host or for all hosts in
Expand Down

0 comments on commit 5eb8a7b

Please sign in to comment.