fix: harden repair backup scope and migrate swap rollback

- repair.py: define backup_path before the conditional block so it is
  always in scope when the except handler references it
- migrate.py: restore old palace from .old if both os.rename and
  shutil.move fail during the swap step
This commit is contained in:
JunghwanNA
2026-04-16 14:04:26 +09:00
parent 5dfe853154
commit fb1cf53919
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -254,8 +254,8 @@ def rebuild_index(palace_path=None):
# Back up ONLY the SQLite database, not the bloated HNSW files
sqlite_path = os.path.join(palace_path, "chroma.sqlite3")
backup_path = sqlite_path + ".backup"
if os.path.exists(sqlite_path):
backup_path = sqlite_path + ".backup"
print(f" Backing up chroma.sqlite3 ({os.path.getsize(sqlite_path) / 1e6:.0f} MB)...")
shutil.copy2(sqlite_path, backup_path)
print(f" Backup: {backup_path}")