@@ -53,14 +53,10 @@ def garbage_collect(self):
5353
5454 def get_repository_chunks (self ) -> ChunkIndex :
5555 """return a chunks index"""
56- if self .stats :
57- # slow but thorough: scan the pack headers for real sizes/locations and to catch objects
58- # missing from the cached index. Start unused (F_NONE); analyze_archives marks used ones.
59- logger .info ("Getting object IDs present in the repository..." )
60- chunks = build_chunkindex_from_repo (self .repository , disable_caches = True , init_flags = ChunkIndex .F_NONE )
61- else : # faster: rely on existing chunks index (with flags F_NONE and size 0).
62- logger .info ("Getting object IDs from cached chunks index..." )
63- chunks = build_chunkindex_from_repo (self .repository , cache_immediately = not self .dry_run )
56+ # The cached index already has each object's obj_size and starts entries as F_NONE, so it
57+ # serves both GC and --stats; no need to force the slow pack-header scan just to get sizes.
58+ logger .info ("Getting object IDs from the cached chunks index..." )
59+ chunks = build_chunkindex_from_repo (self .repository , cache_immediately = not self .dry_run )
6460 return chunks
6561
6662 def save_chunk_index (self ):
@@ -316,15 +312,8 @@ def build_parser_compact(self, subparsers, common_parser, mid_common_parser):
316312 seeing fatal errors when creating backups or when archives are missing in
317313 ``borg repo-list``).
318314
319- When using the ``--stats`` option, borg will internally list all repository
320- objects to determine their existence and stored size. It will build a fresh
321- chunks index from that information and cache it in the repository. For some
322- types of repositories, this might be very slow. It will tell you the sum of
323- stored object sizes, before and after compaction.
324-
325- Without ``--stats``, borg will rely on the cached chunks index to determine
326- existing object IDs (but there is no stored size information in the index,
327- thus it cannot compute before/after compaction size statistics).
315+ With ``--stats``, borg additionally reports the sum of stored object sizes
316+ before and after compaction.
328317 """
329318 )
330319 subparser = ArgumentParser (parents = [common_parser ], description = self .do_compact .__doc__ , epilog = compact_epilog )
@@ -337,7 +326,7 @@ def build_parser_compact(self, subparsers, common_parser, mid_common_parser):
337326 help = "do not change the repository, just show what compact would free" ,
338327 )
339328 subparser .add_argument (
340- "-s" , "--stats" , dest = "stats" , action = "store_true" , help = "print statistics (might be much slower) "
329+ "-s" , "--stats" , dest = "stats" , action = "store_true" , help = "print repository size statistics "
341330 )
342331 subparser .add_argument (
343332 "--threshold" ,
0 commit comments