Browse Source

FIX #4373 (Incorrect borg prune --stats output with --dry-run)

This is a backport of 68aff8b8c4016cf740d2cba952b7b14591f97b0c
user062 6 years ago
parent
commit
133da4dd49
2 changed files with 4 additions and 2 deletions
  1. 3 0
      src/borg/archiver.py
  2. 1 2
      src/borg/testsuite/archiver.py

+ 3 - 0
src/borg/archiver.py

@@ -4360,6 +4360,9 @@ class Archiver:
         args.progress |= is_serve
         self._setup_implied_logging(vars(args))
         self._setup_topic_debugging(args)
+        if getattr(args, 'stats', False) and getattr(args, 'dry_run', False):
+            logger.error("--stats does not work with --dry-run.")
+            return self.exit_code
         if args.show_version:
             logging.getLogger('borg.output.show-version').info('borgbackup version %s' % __version__)
         self.prerun_checks(logger)

+ 1 - 2
src/borg/testsuite/archiver.py

@@ -1844,10 +1844,9 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         self.cmd('init', '--encryption=repokey', self.repository_location)
         self.cmd('create', self.repository_location + '::test1', src_dir)
         self.cmd('create', self.repository_location + '::test2', src_dir)
-        output = self.cmd('prune', '--list', '--stats', '--dry-run', self.repository_location, '--keep-daily=2')
+        output = self.cmd('prune', '--list', '--dry-run', self.repository_location, '--keep-daily=2')
         self.assert_in('Keeping archive: test2', output)
         self.assert_in('Would prune:     test1', output)
-        self.assert_in('Deleted data:', output)
         output = self.cmd('list', self.repository_location)
         self.assert_in('test1', output)
         self.assert_in('test2', output)