def list_checkpoints(self, path):
"""Return a list of checkpoints for a given file"""
cp = self._get_checkpoint_path(None, path)
bucket_name, bucket_path = self.parent._parse_path(cp)
try:
bucket = self.parent._get_bucket(bucket_name)
it = bucket.list_blobs(prefix=bucket_path, delimiter="/",
max_results=self.parent.max_list_size)
checkpoints = [{
"id": os.path.splitext(file.path)[0][-36:],
"last_modified": file.updated,
} for file in islice(it, self.parent.max_list_size)]
except NotFound:
return []
checkpoints.sort(key=lambda c: c["last_modified"], reverse=True)
self.log.debug("list_checkpoints: %s: %s", path, checkpoints)
return checkpoints
评论列表
文章目录