1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-07 18:30:54 +00:00

Export: Check if export path exists

Prevent ``shutil.move`` from moving to .../root
This commit is contained in:
Unrud 2017-07-24 02:31:57 +02:00
parent d069be5189
commit 715a90b33c

View file

@ -130,8 +130,11 @@ def export_storage(config, path, debug=False):
traceback.print_exc()
exit(1)
try:
# This check is prone to a race condition
if os.path.exists(path):
raise Exception("Destination path %r already exists" % path)
shutil.move(os.path.join(temp, "root"), path)
except (OSError, shutil.Error) as e:
except Exception as e:
print("ERROR: Can't create %r directory: %s" % (path, e))
if debug:
traceback.print_exc()