--stats does not work with --dry-run, emit error msg and exit, fixes #4373
This commit is contained in:
user062 2019-03-25 12:44:11 +00:00 committed by TW
parent f541d6e689
commit 68aff8b8c4
2 changed files with 4 additions and 2 deletions

View File

@ -4241,6 +4241,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)

View File

@ -1870,10 +1870,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')
assert re.search(r'Keeping archive \(rule: daily #1\):\s+test2', output)
assert re.search(r'Would prune:\s+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)