From 95a2b1d1cfc82131cbb0911e3999fa4472de24ae Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 26 Jun 2019 17:03:30 +0200 Subject: [PATCH] plugins: unload resources on plugin exit 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 --- plugins/collect_project.lua | 13 +++++++++++++ plugins/cvs.lua | 18 +++++++++++++++++- plugins/files.lua | 18 +++++++++++++++++- plugins/git.lua | 18 +++++++++++++++++- plugins/gitrepo.lua | 20 ++++++++++++++++++-- plugins/licencesrc.lua | 19 ++++++++++++++++++- plugins/svn.lua | 18 +++++++++++++++++- 7 files changed, 117 insertions(+), 7 deletions(-) diff --git a/plugins/collect_project.lua b/plugins/collect_project.lua index 3c88748..9ee19e1 100644 --- a/plugins/collect_project.lua +++ b/plugins/collect_project.lua @@ -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 diff --git a/plugins/cvs.lua b/plugins/cvs.lua index 91b3ea7..2faf9c8 100644 --- a/plugins/cvs.lua +++ b/plugins/cvs.lua @@ -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" } diff --git a/plugins/files.lua b/plugins/files.lua index 2f515fe..4632f0a 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -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", } diff --git a/plugins/git.lua b/plugins/git.lua index b5ed230..735845a 100644 --- a/plugins/git.lua +++ b/plugins/git.lua @@ -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" } diff --git a/plugins/gitrepo.lua b/plugins/gitrepo.lua index d9f2c0f..055e983 100644 --- a/plugins/gitrepo.lua +++ b/plugins/gitrepo.lua @@ -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" } diff --git a/plugins/licencesrc.lua b/plugins/licencesrc.lua index 6734bdd..d94c884 100644 --- a/plugins/licencesrc.lua +++ b/plugins/licencesrc.lua @@ -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" } diff --git a/plugins/svn.lua b/plugins/svn.lua index 94c739c..363f8d7 100644 --- a/plugins/svn.lua +++ b/plugins/svn.lua @@ -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" } -- 2.39.5