From 4304a621bc74d3e792ba94bda605ba8e710d4303 Mon Sep 17 00:00:00 2001 From: Saagar Jha Date: Mon, 6 Dec 2021 17:40:21 -0800 Subject: [PATCH] Use copy2 to copy files This preserves file permissions and other metadata. --- commands/duplicate.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/commands/duplicate.py b/commands/duplicate.py index 3c39ee5..f450ede 100644 --- a/commands/duplicate.py +++ b/commands/duplicate.py @@ -53,9 +53,7 @@ def duplicate(self, dst, input_path): ) else: if not os.path.exists(dst): - with open(dst, "w") as fp: - with open(self.origin, "r") as fpread: - fp.write(fpread.read()) + shutil.copy2(self.origin, dst) self.window.open_file(dst) else: