1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-10 06:03:38 +00:00

check --repair: recreate shadow index, see #6687

before this fix, borg check --repair just created an
empty shadow index, which can lead to incomplete
entries if entries are added later.

and such incomplete (but present) entries can lead to
compact_segments() resurrecting old PUTs by accidentally
dropping related DELs.
This commit is contained in:
Thomas Waldmann 2023-10-29 01:07:16 +02:00
parent 48feb28e11
commit a7809429b3
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -917,6 +917,7 @@ class Repository:
s, _ = self.index[key] s, _ = self.index[key]
self.compact[s] += size self.compact[s] += size
self.segments[s] -= 1 self.segments[s] -= 1
self.shadow_index.setdefault(key, []).append(s)
except KeyError: except KeyError:
pass pass
self.index[key] = segment, offset self.index[key] = segment, offset
@ -935,6 +936,7 @@ class Repository:
self.segments[s] -= 1 self.segments[s] -= 1
size = self.io.read(s, offset, key, read_data=False) size = self.io.read(s, offset, key, read_data=False)
self.compact[s] += size self.compact[s] += size
self.shadow_index.setdefault(key, []).append(s)
elif tag == TAG_COMMIT: elif tag == TAG_COMMIT:
continue continue
else: else: