Skip to content

Commit

Permalink
chore: Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Dec 3, 2024
1 parent 812d0c1 commit d6265ad
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions xmcl-electron-app/main/utils/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { Logger } from '@xmcl/runtime/logger'
import { AbortableTask, BaseTask, Task, task } from '@xmcl/task'
import { spawn } from 'child_process'
import { shell } from 'electron'
import updater, { AppUpdater, CancellationToken, UpdaterSignal } from 'electron-updater'
import { AppUpdater, CancellationToken, UpdaterSignal } from 'electron-updater'
import * as updater from 'electron-updater'
import { createWriteStream } from 'fs'
import { readFile, writeFile } from 'fs-extra'
import { closeSync, existsSync, open, rename, unlink } from 'original-fs'
Expand Down Expand Up @@ -169,27 +170,28 @@ export class DownloadFullUpdateTask extends AbortableTask<void> {
this.cancellationToken = new CancellationToken()

const gfw = await this.app.registry.get(kGFW)

if (gfw.inside) {
// @ts-ignore
const executor = autoUpdater.httpExecutor as any
const executor = this.appUpdater.httpExecutor as any
if (!(kPatched in executor)) {
const createRequest = executor.createRequest.bind(executor)
Object.assign(executor, {
[kPatched]: true,
createRequest: (options: any, callback: any) => {
if (gfw.inside) {
const url = new URL(AZURE_CDN)
options.hostname = url.hostname;
options.path = `/releases/${basename(options.pathname)}`;
options.hostname = url.hostname
options.pathname = `/releases/${basename(options.pathname)}`
options.path = options.pathname
this.app.emit('download-cdn', 'electron', basename(options.pathname))
}
return createRequest(options, callback)
}
},
})
}
}

const signal = new UpdaterSignal(this.appUpdater)
signal.progress((info) => {
this._progress = info.transferred
Expand Down

0 comments on commit d6265ad

Please sign in to comment.