From 38a33c54a657e68903e6ba73ae0509dbeca62b81 Mon Sep 17 00:00:00 2001 From: Jeroen Hoekx Date: Sat, 31 Mar 2012 13:58:15 +0200 Subject: [PATCH] Make copy module idempotent. Check md5sum before overwriting a file. Unconditionally copying changes the timestamp. --- library/copy | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/copy b/library/copy index dcb339d2746..fecfeeafacb 100755 --- a/library/copy +++ b/library/copy @@ -54,11 +54,10 @@ changed = False if os.path.exists(dest): md5sum = os.popen("md5sum %s" % dest).read().split()[0] -os.system("cp %s %s" % (src, dest)) - -md5sum2 = os.popen("md5sum %s" % dest).read().split()[0] +md5sum2 = os.popen("md5sum %s" % src).read().split()[0] if md5sum != md5sum2: + os.system("cp %s %s" % (src, dest)) changed = True # mission accomplished