1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-26 16:04:06 +00:00

repository.scan: fix start_offset

start_offset (from state) is only valid for start_segment, otherwise we must use 0.
This commit is contained in:
Thomas Waldmann 2022-09-20 21:25:36 +02:00
parent 63f736be4f
commit b3c7d8f5f3

View file

@ -1235,6 +1235,10 @@ def scan(self, limit=None, state=None):
# we only scan up to end_segment == transaction_id to only scan **committed** chunks, # we only scan up to end_segment == transaction_id to only scan **committed** chunks,
# avoiding scanning into newly written chunks. # avoiding scanning into newly written chunks.
for segment, filename in self.io.segment_iterator(start_segment, end_segment): for segment, filename in self.io.segment_iterator(start_segment, end_segment):
# the start_offset we potentially got from state is only valid for the start_segment we also got
# from there. in case the segment file vanished meanwhile, the segment_iterator might never
# return a segment/filename corresponding to the start_segment and we must start from offset 0 then.
start_offset = start_offset if segment == start_segment else 0
obj_iterator = self.io.iter_objects(segment, start_offset, read_data=False) obj_iterator = self.io.iter_objects(segment, start_offset, read_data=False)
while True: while True:
try: try:
@ -1244,7 +1248,7 @@ def scan(self, limit=None, state=None):
# higher offsets than one that has an error in the header fields. # higher offsets than one that has an error in the header fields.
break break
if start_offset > 0: if start_offset > 0:
# we are using a marker and the marker points to the last object we have already # we are using a state != None and it points to the last object we have already
# returned in the previous scan() call - thus, we need to skip this one object. # returned in the previous scan() call - thus, we need to skip this one object.
# also, for the next segment, we need to start at offset 0. # also, for the next segment, we need to start at offset 0.
start_offset = 0 start_offset = 0