1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-21 23:33:07 +00:00

rebuild_archives_directory: accelerate by only reading metadata

We are only interested in archive metadata objects here, thus for most repo objects
it is enough to read the repoobj's metadata and determine the object's type.

Only if it is the right type of object, we need to read the full object (metadata
and data).
This commit is contained in:
Thomas Waldmann 2024-11-02 20:16:03 +01:00
parent 299c05287f
commit c35cbc9028
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -1833,6 +1833,16 @@ def valid_archive(obj):
)
for chunk_id, _ in self.chunks.iteritems():
pi.show()
cdata = self.repository.get(chunk_id, read_data=False) # only get metadata
try:
meta = self.repo_objs.parse_meta(chunk_id, cdata, ro_type=ROBJ_DONTCARE)
except IntegrityErrorBase as exc:
logger.error("Skipping corrupted chunk: %s", exc)
self.error_found = True
continue
if meta["type"] != ROBJ_ARCHIVE_META:
continue
# now we know it is an archive metadata chunk, load the full object from the repo:
cdata = self.repository.get(chunk_id)
try:
meta, data = self.repo_objs.parse(chunk_id, cdata, ro_type=ROBJ_DONTCARE)
@ -1841,7 +1851,7 @@ def valid_archive(obj):
self.error_found = True
continue
if meta["type"] != ROBJ_ARCHIVE_META:
continue
continue # should never happen
try:
archive = msgpack.unpackb(data)
# Ignore exceptions that might be raised when feeding msgpack with invalid data