Browse Source

Copy the timestamp etc. by switching to copy2.

master
Jake Gustafson 3 years ago
parent
commit
e737f17513
  1. 5
      forwardfilesync.py

5
forwardfilesync.py

@ -101,6 +101,8 @@ def update_tree(src, dst, level=0, do_trim=False, dot_hidden=False,
elif sub_mt > dst_sub_mt: elif sub_mt > dst_sub_mt:
mode = ">" mode = ">"
elif sub_mt < dst_sub_mt: elif sub_mt < dst_sub_mt:
# mode = "<"
# Don't set any mode, or the newer file will be overwritten!
print(indent + CMD_COMMENT print(indent + CMD_COMMENT
+ "WARNING: \"{}\" is newer on destination!" + "WARNING: \"{}\" is newer on destination!"
"".format(dst_sub_path)) "".format(dst_sub_path))
@ -112,7 +114,8 @@ def update_tree(src, dst, level=0, do_trim=False, dot_hidden=False,
print(indent + CMD_CP + "update:") print(indent + CMD_CP + "update:")
print(indent + CMD_CP + " \"{}\" \"{}\"" print(indent + CMD_CP + " \"{}\" \"{}\""
"".format(sub_path, dst_sub_path)) "".format(sub_path, dst_sub_path))
shutil.copyfile(sub_path, dst_sub_path) # shutil.copyfile(sub_path, dst_sub_path)
shutil.copy2(sub_path, dst_sub_path)
except PermissionError: except PermissionError:
print(indent + CMD_COMMENT + "PermissionError:") print(indent + CMD_COMMENT + "PermissionError:")
print(indent + CMD_COMMENT + " {} \"{}\" \"{}\"" print(indent + CMD_COMMENT + " {} \"{}\" \"{}\""

Loading…
Cancel
Save