mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 04:37:34 +00:00
Merge branch '1.0-maint' into merge-1.0-maint
This commit is contained in:
commit
ba30098079
2 changed files with 14 additions and 1 deletions
|
@ -181,17 +181,22 @@ cdef class NSKeyIterator:
|
|||
cdef HashIndex *index
|
||||
cdef const void *key
|
||||
cdef int key_size
|
||||
cdef int exhausted
|
||||
|
||||
def __cinit__(self, key_size):
|
||||
self.key = NULL
|
||||
self.key_size = key_size
|
||||
self.exhausted = 0
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
if self.exhausted:
|
||||
raise StopIteration
|
||||
self.key = hashindex_next_key(self.index, <char *>self.key)
|
||||
if not self.key:
|
||||
self.exhausted = 1
|
||||
raise StopIteration
|
||||
cdef uint32_t *value = <uint32_t *>(self.key + self.key_size)
|
||||
cdef uint32_t segment = _le32toh(value[0])
|
||||
|
@ -348,17 +353,22 @@ cdef class ChunkKeyIterator:
|
|||
cdef HashIndex *index
|
||||
cdef const void *key
|
||||
cdef int key_size
|
||||
cdef int exhausted
|
||||
|
||||
def __cinit__(self, key_size):
|
||||
self.key = NULL
|
||||
self.key_size = key_size
|
||||
self.exhausted = 0
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
if self.exhausted:
|
||||
raise StopIteration
|
||||
self.key = hashindex_next_key(self.index, <char *>self.key)
|
||||
if not self.key:
|
||||
self.exhausted = 1
|
||||
raise StopIteration
|
||||
cdef uint32_t *value = <uint32_t *>(self.key + self.key_size)
|
||||
cdef uint32_t refcount = _le32toh(value[0])
|
||||
|
|
|
@ -84,8 +84,11 @@ def test_iteritems(self):
|
|||
idx = NSIndex()
|
||||
for x in range(100):
|
||||
idx[H(x)] = x, x
|
||||
all = list(idx.iteritems())
|
||||
iterator = idx.iteritems()
|
||||
all = list(iterator)
|
||||
self.assert_equal(len(all), 100)
|
||||
# iterator is already exhausted by list():
|
||||
self.assert_raises(StopIteration, next, iterator)
|
||||
second_half = list(idx.iteritems(marker=all[49][0]))
|
||||
self.assert_equal(len(second_half), 50)
|
||||
self.assert_equal(second_half, all[50:])
|
||||
|
|
Loading…
Reference in a new issue