Repository: borgbackup/borg

Issue:
no progress bar at the segment cleanup step for delete/prune
when running a delete on a no-append-only repository,
after the decrement references step, there is a cleanup step, which does not show a progress bar

so on a large repo one is left wondering



Discussion:
Guess you mean the `compact()` call, where it compacts the segment files.

exactly

With the --progress handling changes implementing this should be pretty simple.


Resolving patch:
diff --git a/src/borg/repository.py b/src/borg/repository.py
--- a/src/borg/repository.py
+++ b/src/borg/repository.py
@@ -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.')
 
diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
--- a/src/borg/testsuite/archiver.py
+++ b/src/borg/testsuite/archiver.py
@@ -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)
 


Test patch: