Skip to content

Commit cb5dea9

Browse files
committed
make restore system originated agnostic
1 parent c14cbd1 commit cb5dea9

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

backend/app.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,31 @@ def _rewrite_paths_in_db(db_path: Path, old_data_dir: str, new_data_dir: Path) -
14921492
)
14931493
updated += 1
14941494

1495+
# Rewrite relative paths in certificates table (convert \ to / if crossing platforms)
1496+
if sep == "\\": # Windows paths being restored elsewhere
1497+
cursor = conn.execute(
1498+
"SELECT id, cert_path, key_path, csr_path, pwd_path FROM certificates"
1499+
)
1500+
for cert_id, cert_path, key_path, csr_path, pwd_path in cursor.fetchall():
1501+
updates = {}
1502+
if cert_path and "\\" in cert_path:
1503+
updates["cert_path"] = cert_path.replace("\\", "/")
1504+
if key_path and "\\" in key_path:
1505+
updates["key_path"] = key_path.replace("\\", "/")
1506+
if csr_path and "\\" in csr_path:
1507+
updates["csr_path"] = csr_path.replace("\\", "/")
1508+
if pwd_path and "\\" in pwd_path:
1509+
updates["pwd_path"] = pwd_path.replace("\\", "/")
1510+
1511+
if updates:
1512+
set_clause = ", ".join(f"{col} = ?" for col in updates.keys())
1513+
values = list(updates.values()) + [cert_id]
1514+
conn.execute(
1515+
f"UPDATE certificates SET {set_clause} WHERE id = ?",
1516+
values
1517+
)
1518+
updated += len(updates)
1519+
14951520
conn.commit()
14961521
finally:
14971522
conn.close()

0 commit comments

Comments
 (0)