Skip to content
Snippets Groups Projects
Commit 853f1a71 authored by Andreas Domanowski's avatar Andreas Domanowski
Browse files

Write history.json only once

parent 530ff3f5
Branches
No related tags found
1 merge request!1Hedgedoc import
......@@ -43,6 +43,8 @@ def export_from_codimd(instance_url, session_id, export_to):
target_dir = prepare_target_dir(export_to)
num_ok = num_fail = 0
print_block_heading(f"Accessing history and trying to fetch each document")
with open(Path(target_dir, f"history.json"), mode="w") as stream:
json.dump(data, stream)
print("Hold on, this may take a while...")
for row in data["history"]:
document_id = row["id"]
......@@ -51,8 +53,6 @@ def export_from_codimd(instance_url, session_id, export_to):
contents = slurp(f"{document_url}/download", session_id)
with open(Path(target_dir, f"{document_id}.md"), mode="wb") as stream:
stream.write(contents)
with open(Path(target_dir, f"history.json"), mode="w") as stream:
json.dump(data, stream)
num_ok += 1
except HTTPError as error:
# history might reference deleted or otherwise inaccessible notes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment