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:
Tim Abbott 2018-08-13 13:30:43 -07:00
parent 33f576f514
commit d66967f851
2 changed files with 5 additions and 2 deletions

View File

@ -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)

View File

@ -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.")