mirror of
https://github.com/zulip/zulip.git
synced 2026-07-03 21:10:12 +08:00
export: Use tar -C to switch directories.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
6855df0abb
commit
27977eddeb
@ -1874,14 +1874,15 @@ def do_export_realm(
|
||||
|
||||
do_write_stats_file_for_realm_export(output_dir)
|
||||
|
||||
# We need to change back to the current working directory after writing
|
||||
# the tarball to the output directory, otherwise the state is compromised
|
||||
# for our unit tests.
|
||||
reset_dir = os.getcwd()
|
||||
tarball_path = output_dir.rstrip("/") + ".tar.gz"
|
||||
os.chdir(os.path.dirname(output_dir))
|
||||
subprocess.check_call(["tar", "-czf", tarball_path, os.path.basename(output_dir)])
|
||||
os.chdir(reset_dir)
|
||||
subprocess.check_call(
|
||||
[
|
||||
"tar",
|
||||
f"-czf{tarball_path}",
|
||||
f"-C{os.path.dirname(output_dir)}",
|
||||
os.path.basename(output_dir),
|
||||
]
|
||||
)
|
||||
return tarball_path
|
||||
|
||||
|
||||
|
||||
@ -46,7 +46,12 @@ class Command(ZulipBaseCommand):
|
||||
do_export_user(user_profile, output_dir)
|
||||
print(f"Finished exporting to {output_dir}; tarring")
|
||||
tarball_path = output_dir.rstrip("/") + ".tar.gz"
|
||||
|
||||
os.chdir(os.path.dirname(output_dir))
|
||||
subprocess.check_call(["tar", "-czf", tarball_path, os.path.basename(output_dir)])
|
||||
subprocess.check_call(
|
||||
[
|
||||
"tar",
|
||||
f"-czf{tarball_path}",
|
||||
f"-C{os.path.dirname(output_dir)}",
|
||||
os.path.basename(output_dir),
|
||||
]
|
||||
)
|
||||
print(f"Tarball written to {tarball_path}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user