Example #1
0
 def check_md5_obj_path(self, b64_md5, size):
     hex_md5 = util.bytes_to_hex(base64.b64decode(b64_md5))
     path = os.path.join(self._cache_dir, "obj", "md5", hex_md5[:2], hex_md5[2:])
     if os.path.isfile(path) and os.path.getsize(path) == size:
         return path, True
     util.mkdir_exists_ok(os.path.dirname(path))
     return path, False
Example #2
0
 def check_md5_obj_path(self, b64_md5: str, size: int) -> Tuple[str, bool, Callable]:
     hex_md5 = util.bytes_to_hex(base64.b64decode(b64_md5))
     path = os.path.join(self._cache_dir, "obj", "md5", hex_md5[:2], hex_md5[2:])
     opener = self._cache_opener(path)
     if os.path.isfile(path) and os.path.getsize(path) == size:
         return path, True, opener
     util.mkdir_exists_ok(os.path.dirname(path))
     return path, False, opener
Example #3
0
    def _file_url(self, api, entity_name, manifest_entry):
        storage_layout = self._config.get("storageLayout", StorageLayout.V1)
        storage_region = self._config.get("storageRegion", "default")
        md5_hex = util.bytes_to_hex(base64.b64decode(manifest_entry.digest))

        if storage_layout == StorageLayout.V1:
            return "{}/artifacts/{}/{}".format(
                api.settings("base_url"), entity_name, md5_hex
            )
        elif storage_layout == StorageLayout.V2:
            return "{}/artifactsV2/{}/{}/{}/{}".format(
                api.settings("base_url"),
                storage_region,
                entity_name,
                quote(manifest_entry.birth_artifact_id),
                md5_hex,
            )
        else:
            raise Exception("unrecognized storage layout: {}".format(storage_layout))
Example #4
0
 def _file_url(self, api, entity_name, md5):
     md5_hex = util.bytes_to_hex(base64.b64decode(md5))
     return '{}/artifacts/{}/{}'.format(api.settings("base_url"),
                                        entity_name, md5_hex)