Merge pull request #1094 from sfromm/issue1048

Give nice error message if destination directory doesn't exist
This commit is contained in:
Michael DeHaan 2012-09-25 17:12:59 -07:00
commit 5530d771b4

View file

@ -56,6 +56,8 @@ def main():
module.fail_json(msg="Destination %s cannot be a directory" % (dest)) module.fail_json(msg="Destination %s cannot be a directory" % (dest))
md5sum_dest = module.md5(dest) md5sum_dest = module.md5(dest)
else: else:
if not os.path.exists(os.path.dirname(dest)):
module.fail_json(msg="Destination directory %s does not exist" % (os.path.dirname(dest)))
if not os.access(os.path.dirname(dest), os.W_OK): if not os.access(os.path.dirname(dest), os.W_OK):
module.fail_json(msg="Destination %s not writable" % (os.path.dirname(dest))) module.fail_json(msg="Destination %s not writable" % (os.path.dirname(dest)))