Skip to content

Commit

Permalink
rebuild_archives_directory: accelerate by only reading metadata
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
ThomasWaldmann committed Nov 3, 2024
1 parent b0a1d9a commit 4682ce6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,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)
Expand All @@ -1843,7 +1853,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
Expand Down

0 comments on commit 4682ce6

Please sign in to comment.