mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 19:22:44 +08:00
fix(updater): retry slow update downloads from other sources and honour cancel
This commit is contained in:
@@ -15,7 +15,11 @@ import type { Options as ReactMarkdownOptions } from 'react-markdown'
|
||||
|
||||
import { BaseDialog, DialogRef } from '@/components/base'
|
||||
import { useUpdate } from '@/hooks/use-update'
|
||||
import { installCachedUpdate, restartApp } from '@/services/cmds'
|
||||
import {
|
||||
cancelUpdateDownload,
|
||||
installUpdate,
|
||||
restartApp,
|
||||
} from '@/services/cmds'
|
||||
import { showNotice } from '@/services/notice-service'
|
||||
import { useSetUpdateState, useUpdateState } from '@/services/states'
|
||||
import { openExternalUrl } from '@/utils/open-external-url'
|
||||
@@ -270,10 +274,9 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!(await installCachedUpdate(updateInfo.version))) {
|
||||
await updateInfo.downloadAndInstall(onDownloadEvent)
|
||||
if (await installUpdate(updateInfo.version, onDownloadEvent)) {
|
||||
await restartApp()
|
||||
}
|
||||
await restartApp()
|
||||
} catch (err: any) {
|
||||
showNotice.error(err)
|
||||
} finally {
|
||||
@@ -336,7 +339,12 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
okBtn={t('settings.modals.update.actions.update')}
|
||||
cancelBtn={t('shared.actions.cancel')}
|
||||
onClose={() => setOpen(false)}
|
||||
onCancel={() => setOpen(false)}
|
||||
onCancel={() => {
|
||||
if (updateState) {
|
||||
void cancelUpdateDownload().catch(showNotice.error)
|
||||
}
|
||||
setOpen(false)
|
||||
}}
|
||||
onOk={onUpdate}
|
||||
>
|
||||
<Box
|
||||
|
||||
Reference in New Issue
Block a user