diff --git a/dandi/files.py b/dandi/files.py index 513674069..379e32583 100644 --- a/dandi/files.py +++ b/dandi/files.py @@ -961,6 +961,7 @@ def mkzarr() -> str: yield {"status": "initiating upload", "size": total_size} lgr.debug("%s: Beginning upload", asset_path) bytes_uploaded = 0 + need_ingest = False upload_data = ( zarr_id, client.get_url(f"/zarr/{zarr_id}/upload"), @@ -991,6 +992,7 @@ def mkzarr() -> str: ) for upspec in r ] + need_ingest = True for fut in as_completed(futures): try: size = fut.result() @@ -1024,14 +1026,16 @@ def mkzarr() -> str: pluralize(len(old_zarr_files), "file"), ) a.rmfiles(old_zarr_files, reingest=False) - lgr.debug("%s: Waiting for server to calculate Zarr checksum", asset_path) - yield {"status": "server calculating checksum"} - client.post(f"/zarr/{zarr_id}/ingest/") - while True: - sleep(2) - r = client.get(f"/zarr/{zarr_id}/") - if r["status"] == "Complete": - break + need_ingest = True + if need_ingest: + lgr.debug("%s: Waiting for server to calculate Zarr checksum", asset_path) + yield {"status": "server calculating checksum"} + client.post(f"/zarr/{zarr_id}/ingest/") + while True: + sleep(2) + r = client.get(f"/zarr/{zarr_id}/") + if r["status"] == "Complete": + break lgr.info("%s: Asset successfully uploaded", asset_path) yield {"status": "done", "asset": a} diff --git a/dandi/tests/test_upload.py b/dandi/tests/test_upload.py index 0d68e473d..9f328d3a7 100644 --- a/dandi/tests/test_upload.py +++ b/dandi/tests/test_upload.py @@ -219,6 +219,8 @@ def test_upload_zarr(new_dandiset: SampleDandiset) -> None: assert isinstance(asset, RemoteZarrAsset) assert asset.asset_type is AssetType.ZARR assert asset.path == "sample.zarr" + # Test that uploading again without any changes works: + new_dandiset.upload() def test_upload_different_zarr(tmp_path: Path, zarr_dandiset: SampleDandiset) -> None: