mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
import: Use os.path.expanduser when accessing paths.
This fixes an issue where passing a path like `~/exports/foo` would result in a `~` directory being created and the export/import not working correctly.
This commit is contained in:
parent
33f576f514
commit
d66967f851
@ -107,7 +107,7 @@ class Command(ZulipBaseCommand):
|
||||
if output_dir is None:
|
||||
output_dir = tempfile.mkdtemp(prefix="/tmp/zulip-export-")
|
||||
else:
|
||||
output_dir = os.path.realpath(output_dir)
|
||||
output_dir = os.path.realpath(os.path.expanduser(output_dir))
|
||||
if os.path.exists(output_dir):
|
||||
shutil.rmtree(output_dir)
|
||||
os.makedirs(output_dir)
|
||||
|
||||
@ -55,15 +55,18 @@ import a database dump from one or more JSON files."""
|
||||
|
||||
check_subdomain_available(subdomain, from_management_command=True)
|
||||
|
||||
paths = []
|
||||
for path in options['export_paths']:
|
||||
path = os.path.realpath(os.path.expanduser(path))
|
||||
if not os.path.exists(path):
|
||||
print("Directory not found: '%s'" % (path,))
|
||||
exit(1)
|
||||
if not os.path.isdir(path):
|
||||
print("Export file should be folder; if it's a tarball, please unpack it first.")
|
||||
exit(1)
|
||||
paths.append(path)
|
||||
|
||||
for path in options['export_paths']:
|
||||
for path in paths:
|
||||
print("Processing dump: %s ..." % (path,))
|
||||
realm = do_import_realm(path, subdomain)
|
||||
print("Checking the system bots.")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user