From ee4510682f4d7d16d0d83c66dd9aade952bb89b3 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Thu, 11 Jul 2019 15:09:20 -0500 Subject: [PATCH] proton: Remove files before trying to copy over them If the file is a symlink, it could dereference the link and overwrite the pointed-to file. --- proton | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proton b/proton index 543b09cb..5673ea2e 100755 --- a/proton +++ b/proton @@ -130,6 +130,12 @@ def makedirs(path): def try_copy(src, dst): try: + if os.path.isdir(dst): + dstfile = dst + "/" + os.path.basename(src) + if os.path.lexists(dstfile): + os.remove(dstfile) + elif os.path.lexists(dst): + os.remove(dst) shutil.copy(src, dst) except PermissionError as e: if e.errno == errno.EPERM: