Skip to content

Commit 71b06d8

Browse files
fix(io): create parent directory before writing config tmp file
On first launch the app data directory does not exist yet, so the atomic-write temp file open fails with ENOENT and logs an ERROR.
1 parent 023ff19 commit 71b06d8

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/subsearch/io/json_file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def load_json_value(json_file_path: Path, key: str) -> Any:
2323
def dump_json_data(json_file_path: Path, json_data: dict) -> None:
2424
temp_file_path = json_file_path.with_suffix(f"{json_file_path.suffix}.tmp")
2525
try:
26+
json_file_path.parent.mkdir(parents=True, exist_ok=True)
2627
with open(temp_file_path, "w", encoding="utf-8") as file:
2728
json.dump(json_data, file, indent=2, ensure_ascii=False)
2829
file.flush()

0 commit comments

Comments
 (0)