From a3b3a93ef2c2ed1b4ea06257526481855a7572a2 Mon Sep 17 00:00:00 2001 From: Floppyrj45 Date: Thu, 19 Feb 2026 15:57:22 +0100 Subject: [PATCH] Fix gather extract: poll task status before download --- index.html.final | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/index.html.final b/index.html.final index 2b7cb05..0317ea4 100644 --- a/index.html.final +++ b/index.html.final @@ -2594,17 +2594,40 @@ async function doExtract() { return; } - var blob = await r.blob(); - var url = URL.createObjectURL(blob); - var a = document.createElement('a'); - a.href = url; - a.download = 'gather_extract_s' + Math.round(start) + '_d' + Math.round(duration) + '.zip'; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); + var taskData = await r.json(); + if (!taskData.task_id) { + setInfo('Extract error: no task_id returned'); + return; + } + var taskId = taskData.task_id; + setInfo('📥 Processing extract task...'); - setInfo('📥 Downloaded: ' + (blob.size / 1e6).toFixed(1) + ' MB'); + // Poll until done + while (true) { + await new Promise(function(resolve) { setTimeout(resolve, 2000); }); + var sr = await fetch(API + '/tasks/' + taskId); + var sd = await sr.json(); + if (sd.status === 'done') { + setInfo('📥 Downloading ZIP...'); + var dr = await fetch(API + '/tasks/' + taskId + '/download'); + var blob = await dr.blob(); + var url = URL.createObjectURL(blob); + var a = document.createElement('a'); + a.href = url; + a.download = 'gather_extract_s' + Math.round(start) + '_d' + Math.round(duration) + '.zip'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + setInfo('📥 Downloaded: ' + (blob.size / 1e6).toFixed(1) + ' MB'); + break; + } else if (sd.status === 'error') { + setInfo('Extract error: ' + (sd.error || 'unknown')); + break; + } else { + setInfo('📥 Processing... ' + (sd.progress || '')); + } + } } catch(e) { setInfo('Extract error: ' + e.message); }