From 12137ebef807e10db453539958330ea72cd5fc59 Mon Sep 17 00:00:00 2001 From: Jermiah Joseph <44614774+jjjermiah@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:00:25 -0500 Subject: [PATCH] Update src/imgtools/io/writers/abstract_base_writer.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/imgtools/io/writers/abstract_base_writer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/imgtools/io/writers/abstract_base_writer.py b/src/imgtools/io/writers/abstract_base_writer.py index 2208814..b5d1237 100644 --- a/src/imgtools/io/writers/abstract_base_writer.py +++ b/src/imgtools/io/writers/abstract_base_writer.py @@ -292,7 +292,9 @@ def __exit__( logger.debug(f"Exiting context manager for {self.__class__.__name__}") if self.index_file.exists(): logger.debug(f"Removing lock file {self._get_index_lock()}") - self._get_index_lock().unlink() + lock_file = self._get_index_lock() + if lock_file.exists(): + lock_file.unlink() # if the root directory is empty, aka we created it but didn't write anything, delete it if (