Make copy module idempotent.
Check md5sum before overwriting a file. Unconditionally copying changes the timestamp.
This commit is contained in:
parent
6f55ded1c3
commit
645640b88d
1 changed files with 2 additions and 3 deletions
5
copy
5
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
|
||||
|
|
Loading…
Reference in a new issue