[elbe-devel] [PATCH 01/14] elbepack: never clean up tmpdirfilesystem with debug=True

Thomas Weißschuh thomas.weissschuh at linutronix.de
Wed Feb 28 11:34:52 CET 2024


Before the __exit__() method would always delete the directory making
the debug parameter fairly unusable.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/filesystem.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 399f85c37c19..d3571345d868 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -490,20 +490,20 @@ class TmpdirFilesystem (Filesystem):
         self.debug = debug
 
     def __del__(self):
+        self.delete()
+
+    def delete(self):
         # dont delete files in debug mode
         if self.debug:
             print(f'leaving TmpdirFilesystem in "{self.path}"')
         else:
-            self.delete()
-
-    def delete(self):
-        shutil.rmtree(self.path, True)
+            shutil.rmtree(self.path, True)
 
     def __enter__(self):
         return self
 
     def __exit__(self, exec_type, exec_value, tb):
-        shutil.rmtree(self.path)
+        self.delete()
         return False
 
 
-- 
2.44.0



More information about the elbe-devel mailing list