diff --git a/library/copy b/library/copy index f3f3cab6d9..cdd47f41c8 100755 --- a/library/copy +++ b/library/copy @@ -66,6 +66,16 @@ if dest: if not os.path.exists(src): exit_kv(rc=1, failed=1, msg="Source %s failed to transfer" % (src)) +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 if os.path.exists(dest):