Skip to content

Commit

Permalink
Don't crash if dataset_description.json is empty (failed download att…
Browse files Browse the repository at this point in the history
…empt?) (#53)
  • Loading branch information
hoechenberger authored Oct 2, 2021
1 parent 66a62fb commit a0ed4b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
- Add basic support for running Jupyter Notebooks / Jupyter Lab, interactive
IPython sessions, and in the VS Code interactive Jupyter window.

- Don't crash if the local `dataset_description.json` file is empty when trying
to resume an aborted download.

## 2021.8

- Retry downloads if a `ReadError` has occurred.
Expand Down
7 changes: 5 additions & 2 deletions openneuro/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,11 @@ def _get_local_tag(
if not local_json_path.exists():
return None

with local_json_path.open('r', encoding='utf-8') as f:
local_json = json.load(f)
local_json_file_content = local_json_path.read_text(encoding='utf-8')
if not local_json_file_content:
return None

local_json = json.loads(local_json_file_content)

if 'DatasetDOI' not in local_json:
raise RuntimeError('Local "dataset_description.json" does not contain '
Expand Down

0 comments on commit a0ed4b4

Please sign in to comment.