Skip to content

Commit

Permalink
repo-list: print shortened archive IDs
Browse files Browse the repository at this point in the history
256bits (64 hex digits) is a bit much and as borg
can also deal with abbreviated IDs, we only show
32bits (8 hex digits) by default.
  • Loading branch information
ThomasWaldmann committed Sep 26, 2024
1 parent 1b68053 commit 7acedec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/borg/archiver/repo_list_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def do_repo_list(self, args, repository, manifest):
elif args.short:
format = "{id}{NL}"
else:
format = os.environ.get("BORG_RLIST_FORMAT", "{archive:<36} {time} [{id}]{NL}")
format = os.environ.get("BORG_RLIST_FORMAT", "{archive:<36} {time} [{id32}]{NL}")
formatter = ArchiveFormatter(format, repository, manifest, manifest.key, iec=args.iec)

output_data = []
Expand Down
7 changes: 5 additions & 2 deletions src/borg/helpers/parseformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,14 @@ class ArchiveFormatter(BaseFormatter):
"end": "time (end) of creation of the archive",
"command_line": "command line which was used to create the archive",
"id": "internal ID of the archive",
"id32": "internal ID of the archive, first 32 bits",
"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"),
("archive", "name", "comment", "id", "id32"),
("start", "time", "end", "command_line"),
("hostname", "username"),
("size", "nfiles"),
Expand Down Expand Up @@ -816,11 +817,13 @@ def get_item_data(self, archive_info, jsonline=False):
self.id = archive_info.id
item_data = {}
item_data.update({} if jsonline else self.static_data)
id_hex = bin_to_hex(archive_info.id)
item_data.update(
{
"name": archive_info.name,
"archive": archive_info.name,
"id": bin_to_hex(archive_info.id),
"id": id_hex,
"id32": id_hex[:8],
"time": self.format_time(archive_info.ts),
"start": self.format_time(archive_info.ts),
}
Expand Down

0 comments on commit 7acedec

Please sign in to comment.