async def ensure_path(self, path, acl=None): path = self.normalize_path(path) acl = acl or self.default_acl paths_to_make = [] for segment in path[1:].split("/"): if not paths_to_make: paths_to_make.append("/" + segment) continue paths_to_make.append("/".join([paths_to_make[-1], segment])) while paths_to_make: path = paths_to_make[0] if self.features.create_with_stat: request = protocol.Create2Request(path=path, acl=acl) else: request = protocol.CreateRequest(path=path, acl=acl) request.set_flags( ephemeral=False, sequential=False, container=self.features.containers ) try: await self.send(request) except exc.NodeExists: pass paths_to_make.pop(0)
async def ensure_path(self, path, acl=None): """ Ensure all znodes exist in the path. Missing Znodes will be created. :param str path: Path of znode :param aiozk.ACL acl: ACL to be set to the new znodes """ path = self.normalize_path(path) acl = acl or self.default_acl paths_to_make = [] for segment in path[1:].split("/"): if not paths_to_make: paths_to_make.append("/" + segment) continue paths_to_make.append("/".join([paths_to_make[-1], segment])) while paths_to_make: path = paths_to_make[0] if self.features.create_with_stat: request = protocol.Create2Request(path=path, acl=acl) else: request = protocol.CreateRequest(path=path, acl=acl) request.set_flags(ephemeral=False, sequential=False, container=self.features.containers) try: await self.send(request) except exc.NodeExists: pass paths_to_make.pop(0)