recreate: remove special-cased --dry-run

This commit is contained in:
Marian Beermann 2016-12-02 18:15:11 +01:00
parent c6f0969352
commit 30df63c509
2 changed files with 8 additions and 13 deletions

View File

@ -1394,10 +1394,6 @@ class ArchiveChecker:
class ArchiveRecreater: class ArchiveRecreater:
class FakeTargetArchive:
def __init__(self):
self.stats = Statistics()
class Interrupted(Exception): class Interrupted(Exception):
def __init__(self, metadata=None): def __init__(self, metadata=None):
self.metadata = metadata or {} self.metadata = metadata or {}
@ -1434,7 +1430,7 @@ class ArchiveRecreater:
self.stats = stats self.stats = stats
self.progress = progress self.progress = progress
self.print_file_status = file_status_printer or (lambda *args: None) self.print_file_status = file_status_printer or (lambda *args: None)
self.checkpoint_interval = checkpoint_interval self.checkpoint_interval = None if dry_run else checkpoint_interval
def recreate(self, archive_name, comment=None, target_name=None): def recreate(self, archive_name, comment=None, target_name=None):
assert not self.is_temporary_archive(archive_name) assert not self.is_temporary_archive(archive_name)
@ -1444,7 +1440,7 @@ class ArchiveRecreater:
self.matcher_add_tagged_dirs(archive) self.matcher_add_tagged_dirs(archive)
if self.matcher.empty() and not self.recompress and not target.recreate_rechunkify and comment is None: if self.matcher.empty() and not self.recompress and not target.recreate_rechunkify and comment is None:
logger.info("Skipping archive %s, nothing to do", archive_name) logger.info("Skipping archive %s, nothing to do", archive_name)
return True return
self.process_items(archive, target) self.process_items(archive, target)
replace_original = target_name is None replace_original = target_name is None
self.save(archive, target, comment, replace_original=replace_original) self.save(archive, target, comment, replace_original=replace_original)
@ -1588,8 +1584,6 @@ class ArchiveRecreater:
def create_target(self, archive, target_name=None): def create_target(self, archive, target_name=None):
"""Create target archive.""" """Create target archive."""
if self.dry_run:
return self.FakeTargetArchive(), None
target_name = target_name or archive.name + '.recreate' target_name = target_name or archive.name + '.recreate'
target = self.create_target_archive(target_name) target = self.create_target_archive(target_name)
# If the archives use the same chunker params, then don't rechunkify # If the archives use the same chunker params, then don't rechunkify

View File

@ -1102,9 +1102,10 @@ class Archiver:
continue continue
print('Processing', name) print('Processing', name)
recreater.recreate(name, args.comment) recreater.recreate(name, args.comment)
manifest.write() if not args.dry_run:
repository.commit() manifest.write()
cache.commit() repository.commit()
cache.commit()
return self.exit_code return self.exit_code
@with_repository(manifest=False, exclusive=True) @with_repository(manifest=False, exclusive=True)
@ -2387,8 +2388,8 @@ class Archiver:
When rechunking space usage can be substantial, expect at least the entire When rechunking space usage can be substantial, expect at least the entire
deduplicated size of the archives using the previous chunker params. deduplicated size of the archives using the previous chunker params.
When recompressing approximately 1 % of the repository size or 512 MB When recompressing expect approx throughput / checkpoint-interval in space usage,
(whichever is greater) of additional space is used. assuming all chunks are recompressed.
""") """)
subparser = subparsers.add_parser('recreate', parents=[common_parser], add_help=False, subparser = subparsers.add_parser('recreate', parents=[common_parser], add_help=False,
description=self.do_recreate.__doc__, description=self.do_recreate.__doc__,