fix: handle empty/invalid athlete.json in merge, API read, and writer encoding
This commit is contained in:
@@ -382,7 +382,9 @@ def write_athlete_json(summaries: list[dict], output_dir: Path, athlete_config:
|
|||||||
**athlete_config,
|
**athlete_config,
|
||||||
}
|
}
|
||||||
(output_dir / "athlete.json").write_text(
|
(output_dir / "athlete.json").write_text(
|
||||||
json.dumps(athlete, indent=2, ensure_ascii=False)
|
json.dumps(athlete, indent=2, ensure_ascii=False),
|
||||||
|
encoding="utf-8",
|
||||||
|
errors="replace",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,10 @@ async def get_athlete(bincio_session: str | None = Cookie(default=None)) -> JSON
|
|||||||
athlete_path = dd / "athlete.json"
|
athlete_path = dd / "athlete.json"
|
||||||
data: dict = {}
|
data: dict = {}
|
||||||
if athlete_path.exists():
|
if athlete_path.exists():
|
||||||
|
try:
|
||||||
data = json.loads(athlete_path.read_text(encoding="utf-8"))
|
data = json.loads(athlete_path.read_text(encoding="utf-8"))
|
||||||
|
except (json.JSONDecodeError, OSError):
|
||||||
|
pass
|
||||||
# Layer edits/athlete.yaml on top
|
# Layer edits/athlete.yaml on top
|
||||||
edits_path = dd / "edits" / "athlete.yaml"
|
edits_path = dd / "edits" / "athlete.yaml"
|
||||||
if edits_path.exists():
|
if edits_path.exists():
|
||||||
|
|||||||
Reference in New Issue
Block a user