diff --git a/backend/app.py b/backend/app.py index a70ac4a..2774c8f 100644 --- a/backend/app.py +++ b/backend/app.py @@ -154,21 +154,19 @@ def list_sessions(): session_files = [] total_bytes = 0 has_disks = False - for f in sorted(in_dir.iterdir()): - if f.is_file(): - sz = f.stat().st_size - session_files.append({"name": f.name, "size_bytes": sz, "size_gb": round(sz / (1024**3), 1)}) - total_bytes += sz - elif f.is_dir(): - for df in f.rglob("*"): - if df.is_file() and df.suffix.lower() in {".vmdk", ".qcow2", ".img", ".raw", ".vhd", ".vhdx"}: - has_disks = True - break + all_files = sorted([f for f in in_dir.rglob("*") if f.is_file()], key=lambda f: f.stat().st_size, reverse=True) + for f in all_files: + sz = f.stat().st_size + total_bytes += sz + rel = str(f.relative_to(in_dir)) + session_files.append({"name": rel, "size_bytes": sz, "size_gb": round(sz / (1024**3), 1)}) + if f.suffix.lower() in {".vmdk", ".qcow2", ".img", ".raw", ".vhd", ".vhdx"}: + has_disks = True if not session_files: continue sessions.append({ "session_id": entry.name, - "files": session_files, + "files": session_files[:10], "total_size_gb": round(total_bytes / (1024**3), 1), "has_disks": has_disks, })