From 0e2e90322b9e3eee18ec6f2fe824e73eaac7f663 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 27 Mar 2016 10:03:12 +0200 Subject: [PATCH] rmtree only if it is temp dir. If user specifies out_path then do not rmtree it. --- scripts/cdist | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/cdist b/scripts/cdist index 9fa3ddb8..fecf61d0 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -138,13 +138,19 @@ def commandline(): # created in it. if args_dict['out_path'] is None: args.out_path = tempfile.mkdtemp() + is_temp_dir = True + else: + is_temp_dir = False # if remote-exec and/or remote-copy args are None then user # didn't specify command line options nor env vars: # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC if args_dict['remote_copy'] is None or args_dict['remote_exec'] is None: control_path_dir = args.out_path - import atexit - atexit.register(lambda: shutil.rmtree(control_path_dir)) + # only rmtree if it is temp directory; + # if user specifies out_path do not remove it + if is_temp_dir: + import atexit + atexit.register(lambda: shutil.rmtree(control_path_dir)) mux_opts = inspect_ssh_mux_opts(control_path_dir) if args_dict['remote_exec'] is None: args.remote_exec = cdist.REMOTE_EXEC + mux_opts