From 6ae94a0a72b6345b07727ad0713c081352425719 Mon Sep 17 00:00:00 2001 From: Yanray Wang Date: Wed, 26 Jul 2023 17:12:57 +0800 Subject: [PATCH] code_size_compare: make sure _remove_worktree executed Add try and finally to make sure we remove worktree as expected even if we hit errors by accident. Signed-off-by: Yanray Wang --- scripts/code_size_compare.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py index 89d8fe92c..cc43dc75d 100755 --- a/scripts/code_size_compare.py +++ b/scripts/code_size_compare.py @@ -423,9 +423,11 @@ class CodeSizeCalculator: """ git_worktree_path = self._create_git_worktree() - self._build_libraries(git_worktree_path) - res = self._gen_raw_code_size(git_worktree_path) - self._remove_worktree(git_worktree_path) + try: + self._build_libraries(git_worktree_path) + res = self._gen_raw_code_size(git_worktree_path) + finally: + self._remove_worktree(git_worktree_path) return res