Fix gather extract: file-based tasks (multi-worker safe), correct status completed check

This commit is contained in:
Floppyrj45
2026-02-19 16:01:06 +01:00
parent a3b3a93ef2
commit c72ba38221
3 changed files with 36 additions and 2 deletions

Binary file not shown.

View File

@@ -31,7 +31,41 @@ if not os.path.exists(TEMP_DIR):
os.makedirs(TEMP_DIR)
# Global task store
TASKS = {}
import threading
_task_lock = threading.Lock()
_TASK_FILE = '/tmp/seismic_tasks.json'
def _load_tasks():
try:
with open(_TASK_FILE) as f:
return json.load(f)
except:
return {}
def _save_tasks(tasks):
with open(_TASK_FILE, 'w') as f:
json.dump(tasks, f)
class TasksProxy:
def get(self, key, default=None):
return _load_tasks().get(key, default)
def __setitem__(self, key, value):
with _task_lock:
tasks = _load_tasks()
tasks[key] = value
_save_tasks(tasks)
def __getitem__(self, key):
return _load_tasks()[key]
def __contains__(self, key):
return key in _load_tasks()
def pop(self, key, *args):
with _task_lock:
tasks = _load_tasks()
result = tasks.pop(key, *args)
_save_tasks(tasks)
return result
TASKS = TasksProxy()
# ========== UTILITY FUNCTIONS ==========

View File

@@ -2607,7 +2607,7 @@ async function doExtract() {
await new Promise(function(resolve) { setTimeout(resolve, 2000); });
var sr = await fetch(API + '/tasks/' + taskId);
var sd = await sr.json();
if (sd.status === 'done') {
if (sd.status === 'completed') {
setInfo('📥 Downloading ZIP...');
var dr = await fetch(API + '/tasks/' + taskId + '/download');
var blob = await dr.blob();