Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ def info(self):
else:
info |= {
"command_line": self.metadata.command_line,
"cwd": self.metadata.get("cwd", ""),
"hostname": self.metadata.hostname,
"username": self.metadata.username,
"comment": self.metadata.get("comment", ""),
Expand Down Expand Up @@ -692,6 +693,7 @@ def save(self, name=None, comment=None, timestamp=None, stats=None, additional_m
"tags": list(sorted(self.tags)),
"item_ptrs": item_ptrs, # see #1473
"command_line": join_cmd(sys.argv),
"cwd": self.cwd,
"hostname": hostname,
"username": getuser(),
"time": start.isoformat(timespec="microseconds"),
Expand Down
1 change: 1 addition & 0 deletions src/borg/archiver/info_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def do_info(self, args, repository, manifest, cache):
Time (end): {end}
Duration: {duration}
Command line: {command_line}
Working Directory: {cwd}
Number of files: {stats[nfiles]}
Original size: {stats[original_size]}
"""
Expand Down
1 change: 1 addition & 0 deletions src/borg/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'recreate_source_id', 'recreate_args', 'recreate_partial_chunks', # used in 1.1.0b1 .. b2
'size', 'nfiles',
'size_parts', 'nfiles_parts', # legacy v1 archives
'cwd',
])
# fmt: on

Expand Down
3 changes: 2 additions & 1 deletion src/borg/item.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,15 @@ cdef class ArchiveItem(PropDict):
nfiles = PropDictProperty(int)
size_parts = PropDictProperty(int) # legacy only
nfiles_parts = PropDictProperty(int) # legacy only
cwd = PropDictProperty(str, 'surrogate-escaped str')

def update_internal(self, d):
# legacy support for migration (data from old msgpacks comes in as bytes always, but sometimes we want str)
for k, v in list(d.items()):
k = fix_key(d, k)
if k == 'version':
assert isinstance(v, int)
if k in ('name', 'hostname', 'username', 'comment'):
if k in ('name', 'hostname', 'username', 'comment', 'cwd'):
v = fix_str_value(d, k)
if k in ('time', 'time_end'):
v = fix_str_value(d, k, 'replace')
Expand Down
13 changes: 13 additions & 0 deletions src/borg/testsuite/archiver/info_cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os

from ...constants import * # NOQA
from .. import changedir
from . import cmd, checkts, create_regular_file, generate_archiver_tests, RK_ENCRYPTION

pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
Expand Down Expand Up @@ -46,3 +47,15 @@ def test_info_json_of_empty_archive(archivers, request):
assert info_repo["archives"] == []
info_repo = json.loads(cmd(archiver, "info", "--json", "--last=1"))
assert info_repo["archives"] == []


def test_info_working_directory(archivers, request):
archiver = request.getfixturevalue(archivers)
# create a file in input and create the archive from inside the input directory
create_regular_file(archiver.input_path, "file1", size=1)
cmd(archiver, "repo-create", RK_ENCRYPTION)
expected_cwd = os.path.abspath(archiver.input_path)
with changedir(archiver.input_path):
cmd(archiver, "create", "test", ".")
info_archive = cmd(archiver, "info", "-a", "test")
assert f"Working Directory: {expected_cwd}" in info_archive
Loading