mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +00:00
Merge pull request #1519 from enkore/issue/1115
Repository: add compact_segments progress
This commit is contained in:
commit
5859badc29
2 changed files with 12 additions and 3 deletions
|
@ -442,14 +442,17 @@ def complete_xfer(intermediate=True):
|
|||
unused = []
|
||||
|
||||
logger.debug('compaction started.')
|
||||
pi = ProgressIndicatorPercent(total=len(self.compact), msg='Compacting segments %3.0f%%', step=1)
|
||||
for segment, freeable_space in sorted(self.compact.items()):
|
||||
if not self.io.segment_exists(segment):
|
||||
logger.warning('segment %d not found, but listed in compaction data', segment)
|
||||
del self.compact[segment]
|
||||
pi.show()
|
||||
continue
|
||||
segment_size = self.io.segment_size(segment)
|
||||
if segment_size > 0.2 * self.max_segment_size and freeable_space < 0.15 * segment_size:
|
||||
logger.debug('not compacting segment %d (only %d bytes are sparse)', segment, freeable_space)
|
||||
pi.show()
|
||||
continue
|
||||
segments.setdefault(segment, 0)
|
||||
logger.debug('compacting segment %d with usage count %d and %d freeable bytes',
|
||||
|
@ -526,6 +529,8 @@ def complete_xfer(intermediate=True):
|
|||
segments.setdefault(new_segment, 0)
|
||||
assert segments[segment] == 0
|
||||
unused.append(segment)
|
||||
pi.show()
|
||||
pi.finish()
|
||||
complete_xfer(intermediate=False)
|
||||
logger.debug('compaction completed.')
|
||||
|
||||
|
|
|
@ -228,6 +228,8 @@ def tearDown(self):
|
|||
os.chdir(self._old_wd)
|
||||
# note: ignore_errors=True as workaround for issue #862
|
||||
shutil.rmtree(self.tmpdir, ignore_errors=True)
|
||||
# destroy logging configuration
|
||||
logging.Logger.manager.loggerDict.clear()
|
||||
|
||||
def cmd(self, *args, **kw):
|
||||
exit_code = kw.pop('exit_code', 0)
|
||||
|
@ -1044,13 +1046,15 @@ def test_create_dry_run(self):
|
|||
manifest, key = Manifest.load(repository)
|
||||
self.assert_equal(len(manifest.archives), 0)
|
||||
|
||||
def test_progress(self):
|
||||
def test_progress_on(self):
|
||||
self.create_regular_file('file1', size=1024 * 80)
|
||||
self.cmd('init', self.repository_location)
|
||||
# progress forced on
|
||||
output = self.cmd('create', '--progress', self.repository_location + '::test4', 'input')
|
||||
self.assert_in("\r", output)
|
||||
# progress forced off
|
||||
|
||||
def test_progress_off(self):
|
||||
self.create_regular_file('file1', size=1024 * 80)
|
||||
self.cmd('init', self.repository_location)
|
||||
output = self.cmd('create', self.repository_location + '::test5', 'input')
|
||||
self.assert_not_in("\r", output)
|
||||
|
||||
|
|
Loading…
Reference in a new issue