From 1968ead93dcb1693c651290eff97c8662d957735 Mon Sep 17 00:00:00 2001 From: morrison12 Date: Tue, 12 Aug 2025 10:23:01 -0400 Subject: [PATCH 1/2] exclude _chdir from global arguments used when removing temporary file --- pyinfra/connectors/ssh.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyinfra/connectors/ssh.py b/pyinfra/connectors/ssh.py index ff3c1f19d..e42535b21 100644 --- a/pyinfra/connectors/ssh.py +++ b/pyinfra/connectors/ssh.py @@ -517,6 +517,11 @@ def put_file( logger.error("File upload error: {0}".format(output.stderr)) return False + rm_arguments = arguments.copy() + # _chdir is the only one of the global arguments that could require _sudo to succeed + # and _sudo isn't present in arguments as removed above + rm_arguments.pop("_chdir", False) + # Delete the temporary file now that we've successfully copied it command = StringCommand("rm", "-f", temp_file) From 5df58ff134e57a528939f4a3a2ceae073cbb0368 Mon Sep 17 00:00:00 2001 From: morrison12 Date: Mon, 25 Aug 2025 21:52:32 -0400 Subject: [PATCH 2/2] really use rm_arguments --- pyinfra/connectors/ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyinfra/connectors/ssh.py b/pyinfra/connectors/ssh.py index e42535b21..50fb5e7f9 100644 --- a/pyinfra/connectors/ssh.py +++ b/pyinfra/connectors/ssh.py @@ -529,7 +529,7 @@ def put_file( command, print_output=print_output, print_input=print_input, - **arguments, + **rm_arguments, ) if status is False: