]> git.e2factory.org Git - e2factory.git/commitdiff
Add e2lib.cleanup(), to be called before we exit e2.
authorTobias Ulmer <tu@emlix.com>
Wed, 23 Jan 2013 16:08:17 +0000 (17:08 +0100)
committerTobias Ulmer <tu@emlix.com>
Tue, 26 Feb 2013 18:07:14 +0000 (19:07 +0100)
Deduplicates code that needs to run before we exit the e2 process.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua

index eef209c55480537679c157431f101f1203b83689..1f2af8e5f6c476b55f13409b6eb339cb2a290295 100644 (file)
@@ -329,7 +329,7 @@ function e2lib.warnf(category, format, ...)
 end
 
 --- exit, cleaning up temporary files and directories.
--- Return code is '1' and cannot be overrided.
+-- Return code is '1' and cannot be overwritten.
 -- This function takes any number of strings or an error object as arguments.
 -- Please pass error objects to this function in the future.
 -- @param ... an error object, or any number of strings
@@ -346,12 +346,7 @@ function e2lib.abort(...)
         end
         e2lib.log(1, "Error: " .. msg)
     end
-    e2lib.rmtempdirs()
-    e2lib.rmtempfiles()
-    if e2lib.globals.lock then
-        e2lib.globals.lock:cleanup()
-    end
-    os.exit(1)
+    e2lib.finish(1)
 end
 
 --- write a message about an internal error, including a traceback
@@ -532,13 +527,8 @@ function e2lib.rotate_log(file)
     return true, nil
 end
 
---- exit from the tool, cleaning up temporary files and directories
--- @param rc number: return code (optional, defaults to 0)
--- @return This function does not return.
-function e2lib.finish(returncode)
-    if not returncode then
-        returncode = 0
-    end
+--- Clean up temporary files and directories, shut down plugins.
+function e2lib.cleanup()
     local rc, re = plugin.exit_plugins()
     if not rc then
         e2lib.logf(1, "deinitializing plugins failed (ignoring)")
@@ -548,6 +538,16 @@ function e2lib.finish(returncode)
     if e2lib.globals.lock then
         e2lib.globals.lock:cleanup()
     end
+end
+
+--- exit from the tool, cleaning up temporary files and directories
+-- @param rc number: return code (optional, defaults to 0)
+-- @return This function does not return.
+function e2lib.finish(returncode)
+    if not returncode then
+        returncode = 0
+    end
+    e2lib.cleanup()
     os.exit(returncode)
 end