From 2a41d7b0ffc6156c3cda9e2c7aee5dc25a1c6b8c Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 29 Mar 2016 11:47:53 -0700 Subject: [PATCH] always create .start if it doesn't exist Summary:public `rm -rf infer-out && infer --reactive --continue -a capture -- clang -c hello.c` used to crash. closes #315 Differential Revision: D3109673 fb-gh-sync-id: 661bd07 fbshipit-source-id: 661bd07 --- infer/lib/python/infer | 4 ++-- infer/lib/python/inferlib/analyze.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/infer/lib/python/infer b/infer/lib/python/infer index 530c27b07..41435c49b 100755 --- a/infer/lib/python/infer +++ b/infer/lib/python/infer @@ -126,8 +126,8 @@ def main(): if imported_module: analyze.create_results_dir(args.infer_out) - if not args.continue_capture: - analyze.reset_start_file(args.infer_out) + analyze.reset_start_file(args.infer_out, + touch_if_present=not args.continue_capture) utils.configure_logging(args) logging.info('Running command %s', ' '.join(sys.argv)) diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index 909ff079c..bd2f177c2 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -175,10 +175,11 @@ def create_results_dir(results_dir): utils.mkdir_if_not_exists(os.path.join(results_dir, 'sources')) -def reset_start_file(results_dir): - # create new empty file - this will update modified timestamp - open(os.path.join(results_dir, '.start'), 'w').close() - +def reset_start_file(results_dir, touch_if_present=False): + start_path = os.path.join(results_dir, '.start') + if (not os.path.exists(start_path)) or touch_if_present: + # create new empty file - this will update modified timestamp + open(start_path, 'w').close() def clean(infer_out): directories = [