X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/65b22662b8a9370e9a85d8de639283c378a3dad1..f65d320d9f4dda35dcf90c294c494b059b4c36a6:/sdk/python/arvados/http_to_keep.py diff --git a/sdk/python/arvados/http_to_keep.py b/sdk/python/arvados/http_to_keep.py index f2087e4e29..1da8cf4946 100644 --- a/sdk/python/arvados/http_to_keep.py +++ b/sdk/python/arvados/http_to_keep.py @@ -182,6 +182,10 @@ class _Downloader(PyCurlHelper): mt = re.match(r'^HTTP\/(\d(\.\d)?) ([1-5]\d\d) ([^\r\n\x00-\x08\x0b\x0c\x0e-\x1f\x7f]*)\r\n$', self._headers["x-status-line"]) code = int(mt.group(3)) + if not self.name: + logger.error("Cannot determine filename from URL or headers") + return + if code == 200: self.target = self.collection.open(self.name, "wb") @@ -191,6 +195,13 @@ class _Downloader(PyCurlHelper): self._first_chunk = False self.count += len(chunk) + + if self.target is None: + # "If this number is not equal to the size of the byte + # string, this signifies an error and libcurl will abort + # the request." + return 0 + self.target.write(chunk) loopnow = time.time() if (loopnow - self.checkpoint) < 20: @@ -345,7 +356,7 @@ def http_to_keep(api, project_uuid, url, item["properties"].update(properties) api.collections().update(uuid=item["uuid"], body={"collection":{"properties": item["properties"]}}).execute() cr = arvados.collection.CollectionReader(item["portable_data_hash"], api_client=api) - return (item["portable_data_hash"], list(cr.keys())[0]) + return (item["portable_data_hash"], list(cr.keys())[0], item["uuid"], clean_url, now) logger.info("Download complete") @@ -363,4 +374,4 @@ def http_to_keep(api, project_uuid, url, api.collections().update(uuid=c.manifest_locator(), body={"collection":{"properties": properties}}).execute() - return (c.portable_data_hash(), curldownloader.name, c.manifest_locator()) + return (c.portable_data_hash(), curldownloader.name, c.manifest_locator(), clean_url, now)