Skip to content

Commit 709b05e

Browse files
committed
Only remove directories beginning with
1 parent f3cadf4 commit 709b05e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/common/core/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def ensure_cli_env() -> typing.Generator[None, None, None]:
5050
)
5151

5252
if os.path.exists(prometheus_multiproc_dir_name):
53-
_clear_subdirs(prometheus_multiproc_dir_name)
53+
_clear_temporary_directories(prometheus_multiproc_dir_name)
5454

5555
logger.info(
5656
"Re-created %s for Prometheus multi-process mode",
@@ -106,11 +106,11 @@ def main(argv: list[str] = sys.argv) -> None:
106106
execute_from_command_line(argv)
107107

108108

109-
def _clear_subdirs(dir_path: str) -> None:
109+
def _clear_temporary_directories(dir_path: str) -> None:
110110
for filename in os.listdir(dir_path):
111111
file_path = os.path.join(dir_path, filename)
112112
try:
113-
if os.path.isdir(file_path):
113+
if os.path.isdir(file_path) and filename.startswith("tmp"):
114114
shutil.rmtree(file_path)
115115
except Exception as e:
116116
logger.info(f"Failed to delete {file_path}. Reason: {e}")

0 commit comments

Comments
 (0)