fix high priority issues

This commit is contained in:
Davide Scaini
2026-03-31 22:53:50 +02:00
parent e2870c3344
commit f8abab2c23
3 changed files with 40 additions and 16 deletions
+7
View File
@@ -83,6 +83,13 @@ def write_activity(
}
json_path = acts_dir / f"{activity_id}.json"
# Collision guard: if a *different* activity already has this ID, append a
# short hash suffix to disambiguate (same hash = idempotent re-extract).
if json_path.exists():
existing = json.loads(json_path.read_text(encoding="utf-8"))
if existing.get("source_hash") != activity.source_hash:
activity_id = f"{activity_id}-{activity.source_hash[-6:]}"
json_path = acts_dir / f"{activity_id}.json"
json_path.write_text(json.dumps(detail, indent=2, ensure_ascii=False))
# ── GeoJSON track ────────────────────────────────────────────────────────