This commit is contained in:
Ricardo-M-L 2026-04-24 17:27:45 -05:00 committed by GitHub
commit 68ce7731ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -595,10 +595,9 @@ def run_doctor(args):
if state_db_path.exists():
try:
import sqlite3
conn = sqlite3.connect(str(state_db_path))
cursor = conn.execute("SELECT COUNT(*) FROM sessions")
count = cursor.fetchone()[0]
conn.close()
with sqlite3.connect(str(state_db_path)) as conn:
cursor = conn.execute("SELECT COUNT(*) FROM sessions")
count = cursor.fetchone()[0]
check_ok(f"{_DHH}/state.db exists ({count} sessions)")
except Exception as e:
check_warn(f"{_DHH}/state.db exists but has issues: {e}")
@ -617,9 +616,8 @@ def run_doctor(args):
)
if should_fix:
import sqlite3
conn = sqlite3.connect(str(state_db_path))
conn.execute("PRAGMA wal_checkpoint(PASSIVE)")
conn.close()
with sqlite3.connect(str(state_db_path)) as conn:
conn.execute("PRAGMA wal_checkpoint(PASSIVE)")
new_size = wal_path.stat().st_size if wal_path.exists() else 0
check_ok(f"WAL checkpoint performed ({wal_size // 1024}K → {new_size // 1024}K)")
fixed_count += 1