From bf512cd6bbb2d11958587cdffc6efe93738e2f1a Mon Sep 17 00:00:00 2001 From: FluxKit Date: Thu, 19 Feb 2026 14:51:50 +0000 Subject: [PATCH] fix: Use direct Gitea download URLs (no auth needed) --- src/views/BackupView.vue | 48 ++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/src/views/BackupView.vue b/src/views/BackupView.vue index a9e5996..bd5659b 100644 --- a/src/views/BackupView.vue +++ b/src/views/BackupView.vue @@ -47,43 +47,29 @@ async function loadRepos() { } } -async function downloadRepo(repo: Repo) { +function downloadRepo(repo: Repo) { downloading.value = repo.id - try { - const [owner, repoName] = repo.fullName.split('/') - const response = await fetch( - `${import.meta.env.VITE_API_URL || 'https://api.ams.kronos-soulution.de/api'}/backup/download/${owner}/${repoName}?branch=${repo.branch}`, - { - headers: { - 'Authorization': `Bearer ${localStorage.getItem('token')}` - } - } - ) - - if (!response.ok) throw new Error('Download failed') - - const blob = await response.blob() - const url = window.URL.createObjectURL(blob) - const a = document.createElement('a') - a.href = url - a.download = `${repoName}-${repo.branch}.zip` - document.body.appendChild(a) - a.click() - window.URL.revokeObjectURL(url) - document.body.removeChild(a) - - toast.add({ severity: 'success', summary: 'Download', detail: `${repo.name} heruntergeladen`, life: 3000 }) - } catch { - toast.add({ severity: 'error', summary: 'Fehler', detail: 'Download fehlgeschlagen', life: 3000 }) - } finally { + + // Direct download via Gitea URL + const link = document.createElement('a') + link.href = repo.downloadUrl + link.download = `${repo.name}-${repo.branch}.zip` + link.target = '_blank' + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + + toast.add({ severity: 'success', summary: 'Download', detail: `${repo.name} wird heruntergeladen`, life: 3000 }) + + setTimeout(() => { downloading.value = null - } + }, 1000) } async function downloadAll() { for (const repo of repos.value) { - await downloadRepo(repo) - await new Promise(r => setTimeout(r, 500)) // kleine Pause zwischen Downloads + downloadRepo(repo) + await new Promise(r => setTimeout(r, 1000)) } }