Skip to content

Commit

Permalink
Merge pull request #824 from dandi/gh-819
Browse files Browse the repository at this point in the history
Don't error when redownloading the same dandiset.yaml file
  • Loading branch information
yarikoptic committed Oct 28, 2021
2 parents ac5d9f7 + 50079f7 commit d42938c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dandi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
on_windows,
path_is_subpath,
pluralize,
yaml_load,
)

lgr = get_logger()
Expand Down Expand Up @@ -384,8 +385,13 @@ def _populate_dandiset_yaml(dandiset_path, dandiset, existing):
lgr.debug("Updating %s from obtained dandiset metadata", dandiset_metadata_file)
mtime = dandiset.modified
if op.lexists(dandiset_yaml):
with open(dandiset_yaml) as fp:
if yaml_load(fp, typ="safe") == metadata:
yield _skip_file("no change")
return
if existing == "error":
raise FileExistsError(dandiset_yaml)
yield {"status": "error", "message": "already exists"}
return
elif existing == "refresh" and op.lexists(
op.join(dandiset_path, ".git", "annex")
):
Expand All @@ -396,10 +402,10 @@ def _populate_dandiset_yaml(dandiset_path, dandiset, existing):
):
yield _skip_file("already exists")
return
dandiset = Dandiset(dandiset_path, allow_empty=True)
dandiset.path_obj.mkdir(exist_ok=True) # exist_ok in case of parallel race
old_metadata = dandiset.metadata
dandiset.update_metadata(metadata)
ds = Dandiset(dandiset_path, allow_empty=True)
ds.path_obj.mkdir(exist_ok=True) # exist_ok in case of parallel race
old_metadata = ds.metadata
ds.update_metadata(metadata)
os.utime(dandiset_yaml, (time.time(), mtime.timestamp()))
yield {
"status": "done",
Expand Down

0 comments on commit d42938c

Please sign in to comment.