From a42167ca73a4082763f4cc9fbcc2247b9f5e25a0 Mon Sep 17 00:00:00 2001 From: Ingo Gottwald Date: Mon, 25 Jun 2012 20:45:05 +0200 Subject: [PATCH] Copy module: Extended error handling and fixed error messages --- library/copy | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/library/copy b/library/copy index 0686b3994cb..cdd47f41c83 100755 --- a/library/copy +++ b/library/copy @@ -66,11 +66,15 @@ if dest: if not os.path.exists(src): exit_kv(rc=1, failed=1, msg="Source %s failed to transfer" % (src)) -# raise an error if copy has no permission on dest -if not os.access(dest, os.W_OK): - exit_kv(rc=1, failed=1, msg="Destination %s seems not writable" % (dest)) -elif not os.access(dest, os.R_OK): - exit_kv(rc=1, failed=1, msg="Destination %s seems not readable" % (dest)) +if os.path.exists(dest): + # raise an error if copy has no permission on dest + if not os.access(dest, os.W_OK): + exit_kv(rc=1, failed=1, msg="Destination %s not writable" % (dest)) + elif not os.access(dest, os.R_OK): + exit_kv(rc=1, failed=1, msg="Destination %s not readable" % (dest)) +else: + if not os.access(os.path.dirname(dest), os.W_OK): + exit_kv(rc=1, failed=1, msg="Destination %s not writable" % (dest)) md5sum = None changed = False