1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

repository3.list: more efficient implementation

This commit is contained in:
Thomas Waldmann 2024-08-20 13:59:07 +02:00
parent 68e64adb9f
commit 5c325e3254
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -293,16 +293,25 @@ def list(self, limit=None, marker=None):
list <limit> IDs starting from after id <marker>. list <limit> IDs starting from after id <marker>.
""" """
self._lock_refresh() self._lock_refresh()
infos = self.store.list("data") # XXX we can only get the full list from the store collect = True if marker is None else False
try: ids = []
ids = [hex_to_bin(info.name) for info in infos] infos = self.store.list("data") # generator yielding ItemInfos
except StoreObjectNotFound: while True:
ids = [] try:
if marker is not None: info = next(infos)
idx = ids.index(marker) except StoreObjectNotFound:
ids = ids[idx + 1 :] break # can happen e.g. if "data" does not exist, pointless to continue in that case
if limit is not None: except StopIteration:
return ids[:limit] break
else:
id = hex_to_bin(info.name)
if collect:
ids.append(id)
if len(ids) == limit:
break
elif id == marker:
collect = True
# note: do not collect the marker id
return ids return ids
def get(self, id, read_data=True): def get(self, id, read_data=True):