From 4db9a95e6e5ab3474e7a30adb548f6d54fa3bd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Wed, 8 Sep 2021 01:19:00 +0200 Subject: [PATCH] fix: temporary workaround for #28: wait for SHA256 sums to be computed before uploading the next resource --- dcoraid/upload/job.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dcoraid/upload/job.py b/dcoraid/upload/job.py index 0ea26ea..29092b8 100644 --- a/dcoraid/upload/job.py +++ b/dcoraid/upload/job.py @@ -404,6 +404,20 @@ def task_upload_resources(self): exist_ok=True, monitor_callback=self.monitor_callback) self.paths_uploaded.append(path) + # Workaround until `package_revise` is in `resource_add` + # (https://github.com/DCOR-dev/DCOR-Aid/issues/28): + # Wait for the SHA256 sum to be computed by DCOR. + for _ in range(60): + sha256dict = resource_sha256_sums( + dataset_id=self.dataset_id, + api=self.api) + if sha256dict[resource_name] is not None: + break + time.sleep(10) + else: + warnings.warn( + f"SHA256 sum for {self.dataset_id}: " + + f"{resource_name} not yet computed by DCOR!") self.end_time = time.perf_counter() self.set_state("online") else: