public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/, src/pkgcheck/checks/
@ 2022-10-07 12:03 Arthur Zamarin
  0 siblings, 0 replies; only message in thread
From: Arthur Zamarin @ 2022-10-07 12:03 UTC (permalink / raw
  To: gentoo-commits

commit:     3e95ec30077a8833ca9ace821ffec00893771539
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 30 12:24:22 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Oct  7 12:02:46 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=3e95ec30

GitPkgCommitsCheck: cleanup tmpdir after use

Add a cleanup function to Check, which is called for all non-async
checks. This allows us to add a cleanup function for GitPkgCommitsCheck
which removes the temporary directory created for the git repository.

Follows: f889bdae9052a928c8a1f8e7c04043aefe1bf0f8
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/git.py | 14 ++++++++++++--
 src/pkgcheck/feeds.py      |  3 +++
 src/pkgcheck/runners.py    |  3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/pkgcheck/checks/git.py b/src/pkgcheck/checks/git.py
index 4d7190db..046f1843 100644
--- a/src/pkgcheck/checks/git.py
+++ b/src/pkgcheck/checks/git.py
@@ -189,6 +189,9 @@ class _RemovalRepo(UnconfiguredTree):
             f.write('old-repo\n')
         super().__init__(repo_dir)
 
+    def cleanup(self):
+        self.__tmpdir.cleanup()
+
     def __call__(self, pkgs):
         """Update the repo with a given sequence of packages."""
         self._populate(pkgs)
@@ -235,16 +238,23 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck):
         self.repo = self.options.target_repo
         self.valid_arches = self.options.target_repo.known_arches
         self._git_addon = git_addon
+        self._cleanup = []
+
+    def cleanup(self):
+        for repo in self._cleanup:
+            repo.cleanup()
 
     @klass.jit_attr
     def removal_repo(self):
         """Create a repository of packages removed from git."""
-        return _RemovalRepo(self.repo)
+        self._cleanup.append(repo := _RemovalRepo(self.repo))
+        return repo
 
     @klass.jit_attr
     def modified_repo(self):
         """Create a repository of old packages newly modified in git."""
-        return _RemovalRepo(self.repo)
+        self._cleanup.append(repo := _RemovalRepo(self.repo))
+        return repo
 
     @klass.jit_attr
     def added_repo(self):

diff --git a/src/pkgcheck/feeds.py b/src/pkgcheck/feeds.py
index bad5bce0..0edffc2c 100644
--- a/src/pkgcheck/feeds.py
+++ b/src/pkgcheck/feeds.py
@@ -33,6 +33,9 @@ class Feed(base.Addon):
         """Handle functionality against the passed in item."""
         yield from ()
 
+    def cleanup(self):
+        """Do cleanup here."""
+
 
 class QueryCache(Feed):
 

diff --git a/src/pkgcheck/runners.py b/src/pkgcheck/runners.py
index 971ecb94..b87cafb8 100644
--- a/src/pkgcheck/runners.py
+++ b/src/pkgcheck/runners.py
@@ -77,6 +77,9 @@ class SyncCheckRunner(CheckRunner):
             if restrict.match(pkg):
                 yield result
 
+        for check in self.checks:
+            check.cleanup()
+
 
 class RepoCheckRunner(SyncCheckRunner):
     """Generic runner for checks run across an entire repo."""


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-07 12:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-07 12:03 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/, src/pkgcheck/checks/ Arthur Zamarin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox