mirror of https://github.com/borgbackup/borg.git
Changes on filters after feedback
This commit is contained in:
parent
bd7cc38d6e
commit
089995ef73
|
@ -2616,9 +2616,9 @@ class Archiver:
|
||||||
|
|
||||||
group = filters_group.add_mutually_exclusive_group()
|
group = filters_group.add_mutually_exclusive_group()
|
||||||
group.add_argument('--first', dest='first', metavar='N', default=0, type=int,
|
group.add_argument('--first', dest='first', metavar='N', default=0, type=int,
|
||||||
help='consider first N archives after other filter args were applied')
|
help='consider first N archives after other filters were applied')
|
||||||
group.add_argument('--last', dest='last', metavar='N', default=0, type=int,
|
group.add_argument('--last', dest='last', metavar='N', default=0, type=int,
|
||||||
help='consider last N archives after other filter args were applied')
|
help='consider last N archives after other filters were applied')
|
||||||
|
|
||||||
def get_args(self, argv, cmd):
|
def get_args(self, argv, cmd):
|
||||||
"""usually, just returns argv, except if we deal with a ssh forced command for borg serve."""
|
"""usually, just returns argv, except if we deal with a ssh forced command for borg serve."""
|
||||||
|
@ -2687,10 +2687,6 @@ class Archiver:
|
||||||
raise Error('The options --first, --last and --prefix can only be used on repository targets.')
|
raise Error('The options --first, --last and --prefix can only be used on repository targets.')
|
||||||
|
|
||||||
archives = manifest.archives.list(prefix=args.prefix)
|
archives = manifest.archives.list(prefix=args.prefix)
|
||||||
if not archives:
|
|
||||||
logger.critical('There are no archives.')
|
|
||||||
self.exit_code = self.exit_code or EXIT_WARNING
|
|
||||||
return []
|
|
||||||
|
|
||||||
for sortkey in reversed(args.sort_by.split(',')):
|
for sortkey in reversed(args.sort_by.split(',')):
|
||||||
archives.sort(key=attrgetter(sortkey))
|
archives.sort(key=attrgetter(sortkey))
|
||||||
|
|
|
@ -143,7 +143,8 @@ class Archives(abc.MutableMapping):
|
||||||
del self._archives[name]
|
del self._archives[name]
|
||||||
|
|
||||||
def list(self, sort_by=None, reverse=False, prefix=''):
|
def list(self, sort_by=None, reverse=False, prefix=''):
|
||||||
""" Inexpensive Archive.list_archives replacement if we just need .name, .id, .ts
|
"""
|
||||||
|
Inexpensive Archive.list_archives replacement if we just need .name, .id, .ts
|
||||||
Returns list of borg.helpers.ArchiveInfo instances
|
Returns list of borg.helpers.ArchiveInfo instances
|
||||||
"""
|
"""
|
||||||
archives = [x for x in self.values() if x.name.startswith(prefix)]
|
archives = [x for x in self.values() if x.name.startswith(prefix)]
|
||||||
|
|
|
@ -1826,7 +1826,6 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
||||||
self.cmd('create', self.repository_location + '::test', 'input')
|
self.cmd('create', self.repository_location + '::test', 'input')
|
||||||
self.cmd('delete', '--first', '1', '--last', '1', self.repository_location, fork=True, exit_code=2)
|
self.cmd('delete', '--first', '1', '--last', '1', self.repository_location, fork=True, exit_code=2)
|
||||||
|
|
||||||
|
|
||||||
def test_key_export_keyfile(self):
|
def test_key_export_keyfile(self):
|
||||||
export_file = self.output_path + '/exported'
|
export_file = self.output_path + '/exported'
|
||||||
self.cmd('init', self.repository_location, '--encryption', 'keyfile')
|
self.cmd('init', self.repository_location, '--encryption', 'keyfile')
|
||||||
|
|
Loading…
Reference in New Issue