feat: dedup downloads by (url, format_id) index, reuse existing files

This commit is contained in:
mini
2026-02-18 23:00:49 +08:00
parent 25c4973f57
commit 0bab021e21
4 changed files with 36 additions and 4 deletions

View File

@@ -94,8 +94,17 @@ async function startDownload() {
url: url.value, format_id: selectedFormat.value, quality: selectedFormat.value
})
taskId.value = res.data.task_id
statusText.value = 'Starting download...'
pollStatus()
if (res.data.status === 'done') {
// Already downloaded — skip polling, show save button immediately
progress.value = 100
statusText.value = '✅ Already downloaded'
downloadReady.value = true
downloadUrl.value = `/api/file/task/${res.data.task_id}`
downloading.value = false
} else {
statusText.value = 'Starting download...'
pollStatus()
}
} catch (e) {
error.value = e.response?.data?.detail || 'Failed to start download'
downloading.value = false