]> git.e2factory.org Git - e2factory.git/commitdiff
plugins: unload resources on plugin exit
authorTobias Ulmer <tu@emlix.com>
Wed, 26 Jun 2019 15:03:30 +0000 (17:03 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 26 Jun 2019 15:50:56 +0000 (17:50 +0200)
Currently this is only exercised by some unittests. It is one tiny step
towards reloading a project without exiting e2factory.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
plugins/collect_project.lua
plugins/cvs.lua
plugins/files.lua
plugins/git.lua
plugins/gitrepo.lua
plugins/licencesrc.lua
plugins/svn.lua

index 3c88748e4699bc1dbe4d0f374ba4cc90e6189a0a..9ee19e1a1a1ad82fd959c9388577fa07940fccea 100644 (file)
@@ -568,6 +568,19 @@ local function collect_project_init(ctx)
 end
 
 local function collect_project_exit(ctx)
+    local rc, re
+
+    rc, re = result.deregister_result_class("collect_project",
+        collect_project_class)
+    if not rc then
+        return false, re
+    end
+
+    rc, re = result.deregister_type_detection(detect_cp_result)
+    if not rc then
+        return false, re
+    end
+
     return true
 end
 
index 91b3ea743bf686260f86efb226ad67dc15066589..2faf9c86131a8a317bc87594dfb8e8a80b0b70e1 100644 (file)
@@ -506,7 +506,23 @@ plugin_descriptor = {
 
         return true
     end,
-    exit = function (ctx) return true end,
+    exit = function (ctx)
+        local rc, re
+
+        for typ, theclass in result.iterate_result_classes() do
+            if typ == "collect_project" then
+                theclass:remove_source_to_result_fn("cvs", cvs_to_result)
+                break
+            end
+        end
+
+        rc, re = source.deregister_source_class("cvs", cvs.cvs_source)
+        if not rc then
+            return false, re
+        end
+
+        return true
+    end,
     depends = {
         "collect_project.lua"
     }
index 2f515fe8f1473130467a936b9439fc3e67ab3c9c..4632f0aadcb0d7acbe9942a7d630571815f6b85f 100644 (file)
@@ -706,7 +706,23 @@ plugin_descriptor = {
 
         return true
     end,
-    exit = function (ctx) return true end,
+    exit = function (ctx)
+        local rc, re
+
+        for typ, theclass in result.iterate_result_classes() do
+            if typ == "collect_project" then
+                theclass:remove_source_to_result_fn("files", files_to_result)
+                break
+            end
+        end
+
+        rc, re = source.deregister_source_class("files", files.files_source)
+        if not rc then
+            return false, re
+        end
+
+        return true
+    end,
     depends = {
         "collect_project.lua",
     }
index b5ed230e05eb4d4fdbe602664979396e07813bd5..735845ac3ca02bcbb50c2dd23b284c2c5c61f412 100644 (file)
@@ -992,7 +992,23 @@ end
 plugin_descriptor = {
     description = "Git SCM Plugin",
     init = git_plugin_init,
-    exit = function (ctx) return true end,
+    exit = function (ctx)
+        local rc, re
+
+        for typ, theclass in result.iterate_result_classes() do
+            if typ == "collect_project" then
+                theclass:remove_source_to_result_fn("git", git_to_result)
+                break
+            end
+        end
+
+        rc, re = source.deregister_source_class("git", git.git_source)
+        if not rc then
+            return false, re
+        end
+
+        return true
+    end,
     depends = {
         "collect_project.lua"
     }
index d9f2c0ff9d653221b7fdee5d662faf73c1f9da6e..055e9835d540e5967de859dc874fd9b74f57b322 100644 (file)
@@ -646,7 +646,7 @@ end
 
 --------------------------------------------------------------------------------
 
-local function gitrepo_plugin_init()
+local function gitrepo_plugin_init(ctx)
     local rc, re
 
     rc, re = source.register_source_class("gitrepo", gitrepo_source)
@@ -671,7 +671,23 @@ end
 plugin_descriptor = {
     description = "Provides Git repository as source",
     init = gitrepo_plugin_init,
-    exit = function(ctx) return true end,
+    exit = function (ctx)
+        local rc, re
+
+        for typ, theclass in result.iterate_result_classes() do
+            if typ == "collect_project" then
+                theclass:remove_source_to_result_fn("gitrepo", gitrepo_to_result)
+                break
+            end
+        end
+
+        rc, re = source.deregister_source_class("gitrepo", gitrepo_source)
+        if not rc then
+            return false, re
+        end
+
+        return true
+    end,
     depends = {
         "collect_project.lua"
     }
index 6734bddbeb1e1f7c89466b6731f7502059b94d45..d94c88451ec2335e325c083ae5d8aed9f25d7ade 100644 (file)
@@ -429,7 +429,24 @@ plugin_descriptor = {
 
         return true
     end,
-    exit = function (ctx) return true end,
+    exit = function (ctx)
+        local rc, re
+
+        for typ, theclass in result.iterate_result_classes() do
+            if typ == "collect_project" then
+                theclass:remove_source_to_result_fn("licence",
+                    licences_to_result)
+                break
+            end
+        end
+
+        rc, re = source.deregister_source_class("licence", licence_source)
+        if not rc then
+            return false, re
+        end
+
+        return true
+    end,
     depends = {
         "collect_project.lua"
     }
index 94c739c876a501b970aa7287db027649e18c33a7..363f8d7adde2eceac100fceb519bae30335720c0 100644 (file)
@@ -539,7 +539,23 @@ plugin_descriptor = {
 
         return true
     end,
-    exit = function (ctx) return true end,
+    exit = function (ctx)
+        local rc, re
+
+        for typ, theclass in result.iterate_result_classes() do
+            if typ == "collect_project" then
+                theclass:remove_source_to_result_fn("svn", svn_to_result)
+                break
+            end
+        end
+
+        rc, re = source.deregister_source_class("svn", svn.svn_source)
+        if not rc then
+            return false, re
+        end
+
+        return true
+    end,
     depends = {
         "collect_project.lua"
     }