From 7aaa0d1553ae9f244d799a100dd9428b94dda817 Mon Sep 17 00:00:00 2001 From: Claus Lohmar Date: Mon, 27 Jul 2026 12:37:38 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20resilient=20file=20lookup=20=E2=80=94=20?= =?UTF-8?q?walk=20directory=20if=20exact=20path=20not=20found;=20use=20res?= =?UTF-8?q?ume=5Ffile=20for=20sessions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app.py | 6 ++++++ backend/converter.py | 13 ++++++++++++- frontend/templates/index.html | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/backend/app.py b/backend/app.py index 1d04826..17f282e 100644 --- a/backend/app.py +++ b/backend/app.py @@ -145,12 +145,18 @@ def list_sessions(): continue archives = {".7z", ".zip", ".rar", ".tar.gz", ".tgz", ".tar", ".gz", ".bz2", ".xz", ".ova"} has_source = has_disks or any(f["name"].lower().endswith(tuple(archives)) for f in session_files) + resume_file = session_files[0]["name"] + for f in session_files: + if f["name"].lower().endswith(tuple(archives)) or f["name"].lower().endswith((".vmdk", ".qcow2", ".vdi")): + resume_file = f["name"] + break sessions.append({ "session_id": entry.name, "files": session_files[:10], "total_size_gb": round(total_bytes / (1024**3), 1), "has_disks": has_disks, "resumable": has_source, + "resume_file": resume_file, }) except Exception: pass diff --git a/backend/converter.py b/backend/converter.py index b536b5e..1932e62 100644 --- a/backend/converter.py +++ b/backend/converter.py @@ -52,7 +52,18 @@ def extract_if_needed(filename: str) -> Path: if not filepath.is_absolute(): filepath = STAGING_ROOT / filename if not filepath.exists(): - raise FileNotFoundError(f"Source not found: {filepath}") + # Try finding by name — walk the parent directory + parent = filepath.parent + fname = filepath.name + if parent.exists() and parent.is_dir(): + found = list(parent.rglob(fname)) + if found: + filepath = found[0] + logger.info("Found by name: %s", filepath) + else: + raise FileNotFoundError(f"Source not found: {filepath}") + else: + raise FileNotFoundError(f"Source not found: {filepath}") # Detect archive type name = filepath.name.lower() diff --git a/frontend/templates/index.html b/frontend/templates/index.html index 585f903..8a15d98 100644 --- a/frontend/templates/index.html +++ b/frontend/templates/index.html @@ -91,13 +91,13 @@ async function loadSessions() { for (var i = 0; i < sessions.length; i++) { var s = sessions[i]; var fileNames = s.files.map(function(f) { return f.name; }).join(', '); - var firstFile = s.files[0].name; + var resumeFile = s.resume_file || s.files[0].name; html += '
'; html += '
' + s.session_id.substring(0, 8) + ' — ' + fileNames + ' (' + s.total_size_gb + ' GiB)'; if (s.has_disks) html += ' extracted'; html += '
'; if (s.resumable) { - html += ''; + html += ''; } html += ''; html += '
';