Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix: allow users cancel backend download (#6582)
Louis7fe58d6bee66
diff --git a/extensions/llamacpp-extension/src/backend.ts b/extensions/llamacpp-extension/src/backend.tsindex c0fc7093d..7f5e8a22b 100644--- a/extensions/llamacpp-extension/src/backend.ts+++ b/extensions/llamacpp-extension/src/backend.ts@@ -319,7 +319,10 @@ export async function downloadBackend(events.emit('onFileDownloadSuccess', { modelId: taskId, downloadType })} catch (error) {// Fallback: if GitHub fails, retry once with CDN- if (source === 'github') {+ if (+ source === 'github' &&+ error?.toString() !== 'Error: Download cancelled'+ ) {console.warn(`GitHub download failed, falling back to CDN:`, error)return await downloadBackend(backend, version, 'cdn')}diff --git a/web-app/src/containers/DownloadManegement.tsx b/web-app/src/containers/DownloadManegement.tsxindex 92bb3ee85..e0d829740 100644--- a/web-app/src/containers/DownloadManegement.tsx+++ b/web-app/src/containers/DownloadManegement.tsx@@ -400,23 +400,33 @@ export function DownloadManagement() {className="text-main-view-fg/70 cursor-pointer"title="Cancel download"onClick={() => {- serviceHub- .models()- .abortDownload(download.name)- .then(() => {- toast.info(- t('common:toast.downloadCancelled.title'),- {- id: 'cancel-download',- description: t(- 'common:toast.downloadCancelled.description'- ),- }+ // TODO: Consolidate cancellation logic+ if (download.id.startsWith('llamacpp')) {+ const downloadManager =+ window.core.extensionManager.getByName(+ '@janhq/download-extension')- if (downloadProcesses.length === 0) {- setIsPopoverOpen(false)- }- })++ downloadManager.cancelDownload(download.id)+ } else {+ serviceHub+ .models()+ .abortDownload(download.name)+ .then(() => {+ toast.info(+ t('common:toast.downloadCancelled.title'),+ {+ id: 'cancel-download',+ description: t(+ 'common:toast.downloadCancelled.description'+ ),+ }+ )+ if (downloadProcesses.length === 0) {+ setIsPopoverOpen(false)+ }+ })+ }}}/></div>