diff --git a/scripts/git-upload b/scripts/git-upload index 5298b693af..db554b48f7 100755 --- a/scripts/git-upload +++ b/scripts/git-upload @@ -96,14 +96,14 @@ def do_copy(args): src = args.src dst = args.dst - try: - if src.is_dir(): - shutil.copytree(src, dst) - else: - shutil.copy(src, dst) - except FileExistsError: - if args.forbid_overwrite: - raise + if args.forbid_overwrite and dst.exists(): + raise FileExistsError(f"File exists: '{dst}'") + + if src.is_dir(): + shutil.rmtree(dst, ignore_errors=True) + shutil.copytree(src, dst) + else: + shutil.copy(src, dst) def main():