mirror of
https://github.com/skoelle/icloud-contacts-sync.git
synced 2026-09-17 15:30:24 +00:00
sync more logging when error
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
.env
|
||||
config/accounts.json
|
||||
.venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.DS_Store
|
||||
|
||||
@@ -108,7 +108,13 @@ def upsert_contacts(conn, contacts: list[dict], run_id: str):
|
||||
f"INSERT INTO contacts ({', '.join(cols)}) VALUES ({placeholders}) "
|
||||
f"ON DUPLICATE KEY UPDATE {update_clause}"
|
||||
)
|
||||
cur.execute(sql, list(c.values()))
|
||||
try:
|
||||
cur.execute(sql, list(c.values()))
|
||||
except Exception as exc:
|
||||
logger.error("INSERT fehlgeschlagen für UID %s: %s", c.get("uid"), exc)
|
||||
logger.error("SQL: %s", sql[:500])
|
||||
logger.error("Values: %s", {k: v for k, v in c.items() if k != "raw_vcard"})
|
||||
raise
|
||||
conn.commit()
|
||||
|
||||
|
||||
@@ -202,6 +208,11 @@ def replace_all_contacts_for_account(conn, account: str, contacts: list[dict], r
|
||||
c = _sanitize_contact(c)
|
||||
cols = ", ".join(c.keys())
|
||||
placeholders = ", ".join(["%s"] * len(c))
|
||||
cur.execute(f"INSERT INTO contacts ({cols}) VALUES ({placeholders})", list(c.values()))
|
||||
try:
|
||||
cur.execute(f"INSERT INTO contacts ({cols}) VALUES ({placeholders})", list(c.values()))
|
||||
except Exception as exc:
|
||||
logger.error("INSERT fehlgeschlagen für UID %s: %s", c.get("uid"), exc)
|
||||
logger.error("Values: %s", {k: v for k, v in c.items() if k != "raw_vcard"})
|
||||
raise
|
||||
conn.commit()
|
||||
logger.info("Voller Re-Sync für Account %s abgeschlossen: %d Kontakte", account, len(contacts))
|
||||
|
||||
+5
-1
@@ -94,7 +94,11 @@ def sync_account(conn, account, href_to_uid_cache: dict):
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.exception("[%s] Sync-Lauf %s fehlgeschlagen", account.name, run_id)
|
||||
db.finish_sync_run(conn, run_id, "failed", error_message=str(exc))
|
||||
print(f"SYNC-FEHLER [{account.name}]: {exc}", file=sys.stderr)
|
||||
detail = str(exc)
|
||||
if "Unknown column" in detail:
|
||||
detail += " — Fehlende Spalte? ALTER TABLE ausführen: siehe sql/schema.sql"
|
||||
db.finish_sync_run(conn, run_id, "failed", error_message=detail)
|
||||
raise
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user