From 7af347b6be5d5ed2ee0a53418c84e970a5aedabd Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Thu, 4 Jun 2026 20:24:58 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20/api/backups=20=E2=80=94=20fpath.st=5Fsi?= =?UTF-8?q?ze=20->=20fpath.stat().st=5Fsize=20+=20try/except?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/main.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/main.py b/backend/main.py index 43f19b9..5ccc1d9 100644 --- a/backend/main.py +++ b/backend/main.py @@ -3280,7 +3280,8 @@ async def api_backups_list( ): """List all backups across vaults, grouped by file.""" result = [] - for vault_name in index.keys(): + try: + for vault_name in index.keys(): if vault and vault_name != vault: continue if not check_vault_access(vault_name, current_user): @@ -3298,7 +3299,8 @@ async def api_backups_list( for fpath in vault_backup_dir.rglob("*.bak"): if not fpath.is_file(): continue - stat = fpath.st_size + st = fpath.stat() + fsize = st.st_size ts_part = fpath.name.rsplit(".", 2) if len(ts_part) < 3 or not ts_part[-2].isdigit(): continue @@ -3311,13 +3313,16 @@ async def api_backups_list( "backup_file": fpath.name, "timestamp": ts, "datetime": datetime.fromtimestamp(ts, tz=timezone.utc).isoformat(), - "size": stat, + "size": fsize, "full_path": str(fpath), }) - result.sort(key=lambda x: x["timestamp"], reverse=True) - total_size = sum(r["size"] for r in result) - return {"backups": result, "total": len(result), "total_size_bytes": total_size} + result.sort(key=lambda x: x["timestamp"], reverse=True) + total_size = sum(r["size"] for r in result) + return {"backups": result, "total": len(result), "total_size_bytes": total_size} + except Exception as e: + logger.error(f"Error listing backups: {type(e).__name__}: {e}", exc_info=True) + raise HTTPException(status_code=500, detail=f"Erreur listing backups: {str(e)}") @app.post("/api/backups/delete")