1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

rlist: add size and nfiles to format keys, fixes #6086

This commit is contained in:
Thomas Waldmann 2023-04-07 14:34:21 +02:00
parent 355a50225f
commit 7a2c757c69
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 18 additions and 0 deletions

View file

@ -672,11 +672,14 @@ class ArchiveFormatter(BaseFormatter):
"id": "internal ID of the archive",
"hostname": "hostname of host on which this archive was created",
"username": "username of user who created this archive",
"size": "size of this archive (data plus metadata, not considering compression and deduplication)",
"nfiles": "count of files in this archive",
}
KEY_GROUPS = (
("archive", "name", "comment", "id"),
("start", "time", "end", "command_line"),
("hostname", "username"),
("size", "nfiles"),
)
@classmethod
@ -726,6 +729,8 @@ def __init__(self, format, repository, manifest, key, *, json=False, iec=False):
"username": partial(self.get_meta, "username", ""),
"comment": partial(self.get_meta, "comment", ""),
"command_line": partial(self.get_meta, "command_line", ""),
"size": partial(self.get_meta, "size", 0),
"nfiles": partial(self.get_meta, "nfiles", 0),
"end": self.get_ts_end,
}
self.used_call_keys = set(self.call_keys) & self.format_keys

View file

@ -40,6 +40,19 @@ def test_archives_format(self):
self.assert_in("test-1 comment 1" + os.linesep, output_3)
self.assert_in("test-2 comment 2" + os.linesep, output_3)
def test_size_nfiles(self):
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
self.create_regular_file("file1", size=123000)
self.create_regular_file("file2", size=456)
self.cmd(f"--repo={self.repository_location}", "create", "test", "input/file1", "input/file2")
output = self.cmd(f"--repo={self.repository_location}", "list", "test")
print(output)
output = self.cmd(f"--repo={self.repository_location}", "rlist", "--format", "{name} {nfiles} {size}")
o_t = output.split()
assert o_t[0] == "test"
assert int(o_t[1]) == 2
assert 123456 <= int(o_t[2]) < 123999 # there is some metadata overhead
def test_date_matching(self):
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
earliest_ts = "2022-11-20T23:59:59"