Skip to content

Commit

Permalink
Export: Check if export path exists
Browse files Browse the repository at this point in the history
Prevent ``shutil.move`` from moving to .../root
  • Loading branch information
Unrud committed Jul 24, 2017
1 parent d069be5 commit 715a90b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion radicale/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 715a90b

Please sign in to comment.