Repository: borgbackup/borg

Issue:
Borg config --list does not show last_segment_checked
## Have you checked borgbackup docs, FAQ, and open Github issues?

Yes

## Is this a BUG / ISSUE report or a QUESTION?

BUG

## System information. For client/server mode post info for both machines.

1.2.0a8 / also master

#### Full borg commandline that lead to the problem (leave away excludes and passwords)

`borg config --list /path/to/repo`

## Describe the problem you're observing.

If a partial check has started and has been stopped due to timeout, the config file contains the `last_segment_checked` key with an int value.
You can verify that with `borg config /path/to/repo last_segment_checked`, which prints the segment number.

Now try `borg config --list /path/to/repo`: The last_segment_checked is missing.

Reason: In source code of archiver.py `last_segment_checked` is not read when the list subcommand is executed.

I will create a PR for this.


Discussion:

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -1659,7 +1659,7 @@ def do_config(self, args, repository):
         def repo_validate(section, name, value=None, check_value=True):
             if section not in ['repository', ]:
                 raise ValueError('Invalid section')
-            if name in ['segments_per_dir', 'max_segment_size', 'storage_quota', ]:
+            if name in ['segments_per_dir', 'max_segment_size', 'storage_quota', 'last_segment_checked', ]:
                 if check_value:
                     try:
                         int(value)
@@ -1716,6 +1716,11 @@ def list_config(config):
                     if value is None:
                         raise Error('The repository config is missing the %s key which has no default value' % key)
                 print('%s = %s' % (key, value))
+            for key in ['last_segment_checked', ]:
+                value = config.get('repository', key, fallback=None)
+                if value is None:
+                    continue
+                print('%s = %s' % (key, value))
 
         if not args.list:
             if args.name is None:
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
@@ -2991,6 +2991,17 @@ def test_config(self):
         self.assert_in('append_only', output)
         self.assert_in('additional_free_space', output)
         self.assert_in('id', output)
+        self.assert_not_in('last_segment_checked', output)
+
+        output = self.cmd('config', self.repository_location, 'last_segment_checked', exit_code=1)
+        self.assert_in('No option ', output)
+        self.cmd('config', self.repository_location, 'last_segment_checked', '123')
+        output = self.cmd('config', self.repository_location, 'last_segment_checked')
+        assert output == '123' + '\n'
+        output = self.cmd('config', '--list', self.repository_location)
+        self.assert_in('last_segment_checked', output)
+        self.cmd('config', '--delete', self.repository_location, 'last_segment_checked')
+
         for cfg_key, cfg_value in [
             ('additional_free_space', '2G'),
             ('repository.append_only', '1'),
@@ -3002,6 +3013,7 @@ def test_config(self):
             assert output == cfg_value + '\n'
             self.cmd('config', '--delete', self.repository_location, cfg_key)
             self.cmd('config', self.repository_location, cfg_key, exit_code=1)
+
         self.cmd('config', '--list', '--delete', self.repository_location, exit_code=2)
         self.cmd('config', self.repository_location, exit_code=2)
         self.cmd('config', self.repository_location, 'invalid-option', exit_code=1)


Test patch: