From f3d7bee8e14fefb5a1015071a40e4b9e0b625988 Mon Sep 17 00:00:00 2001 From: u348095 Date: Tue, 31 Jul 2012 14:40:50 +1000 Subject: [PATCH] Allow copy dest argument to be a directory Could have used shutil.copy rather than shutil.copyfile, but this implementation preserves the md5 comparison to avoid unnecessary copies --- copy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/copy b/copy index b6021c7b695..66b5921d719 100755 --- a/copy +++ b/copy @@ -45,6 +45,9 @@ def main(): module.fail_json(msg="Destination %s not writable" % (dest)) if not os.access(dest, os.R_OK): module.fail_json(msg="Destination %s not readable" % (dest)) + # Allow dest to be directory without compromising md5 check + if (os.path.isdir(dest)): + dest = os.join(dest, os.path.basename(src)) md5sum_dest = module.md5(dest) else: if not os.access(os.path.dirname(dest), os.W_OK):