From ccbbb48a36598c332bbd6b54daebdecb98fd5a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Mon, 26 Feb 2018 17:30:15 +0100 Subject: [PATCH] Only delete sub path if not empty --- kiwi/path.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kiwi/path.py b/kiwi/path.py index a1a8e037..0afdf39b 100644 --- a/kiwi/path.py +++ b/kiwi/path.py @@ -103,14 +103,17 @@ class Path(object): ] for path_index in reversed(range(0, len(path_elements))): sub_path = os.sep.join(path_elements[0:path_index]) - if path_elements[path_index - 1] in protected_elements: - log.warning( - 'remove_hierarchy: path {0} is protected'.format(sub_path) + if sub_path: + if path_elements[path_index - 1] in protected_elements: + log.warning( + 'remove_hierarchy: path {0} is protected'.format( + sub_path + ) + ) + return + Command.run( + ['rmdir', '--ignore-fail-on-non-empty', sub_path] ) - return - Command.run( - ['rmdir', '--ignore-fail-on-non-empty', sub_path] - ) @classmethod def which(