Skip to content

Commit

Permalink
Merge pull request #8613 from ThomasWaldmann/compact-dry-run-master
Browse files Browse the repository at this point in the history
compact: support --dry-run (do nothing), fixes #8300
  • Loading branch information
ThomasWaldmann authored Dec 29, 2024
2 parents 35c56b9 + 1559a1e commit f9f1d21
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/borg/archiver/compact_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class CompactMixIn:
@with_repository(exclusive=True, compatibility=(Manifest.Operation.DELETE,))
def do_compact(self, args, repository, manifest):
"""Collect garbage in repository"""
ArchiveGarbageCollector(repository, manifest, stats=args.stats).garbage_collect()
if not args.dry_run: # support --dry-run to simplify scripting
ArchiveGarbageCollector(repository, manifest, stats=args.stats).garbage_collect()

def build_parser_compact(self, subparsers, common_parser, mid_common_parser):
from ._common import process_epilog
Expand Down Expand Up @@ -234,7 +235,7 @@ def build_parser_compact(self, subparsers, common_parser, mid_common_parser):
help="compact repository",
)
subparser.set_defaults(func=self.do_compact)

subparser.add_argument("-n", "--dry-run", dest="dry_run", action="store_true", help="do nothing")
subparser.add_argument(
"-s", "--stats", dest="stats", action="store_true", help="print statistics (might be much slower)"
)

0 comments on commit f9f1d21

Please sign in to comment.