From e737f17513a5f642d43ecf857121d13ad20ee76c Mon Sep 17 00:00:00 2001 From: Jake Gustafson <7557867+poikilos@users.noreply.github.com> Date: Mon, 21 Jun 2021 15:09:08 -0400 Subject: [PATCH] Copy the timestamp etc. by switching to copy2. --- forwardfilesync.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forwardfilesync.py b/forwardfilesync.py index ed3080c..dfd06d1 100644 --- a/forwardfilesync.py +++ b/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: mode = ">" elif sub_mt < dst_sub_mt: + # mode = "<" + # Don't set any mode, or the newer file will be overwritten! print(indent + CMD_COMMENT + "WARNING: \"{}\" is newer on destination!" "".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 + " \"{}\" \"{}\"" "".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: print(indent + CMD_COMMENT + "PermissionError:") print(indent + CMD_COMMENT + " {} \"{}\" \"{}\""