diff options
-rw-r--r-- | pym/gentoolkit/eclean/search.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py index 3610920..2eebcfd 100644 --- a/pym/gentoolkit/eclean/search.py +++ b/pym/gentoolkit/eclean/search.py @@ -5,12 +5,13 @@ import os +import shlex import stat import sys -import shlex from functools import partial from inspect import signature -from typing import Optional +from pathlib import Path +from typing import Optional, Set import portage from portage.dep import Atom, use_reduce @@ -136,7 +137,7 @@ class DistfilesSearch: # gather the files to be cleaned self.output("...checking limits for %d ebuild sources" % len(pkgs)) - vcs = self.vcs_check(_distdir) + vcs = self.vcs_check(Path(_distdir)) checks = self._get_default_checks(size_limit, time_limit, exclude, destructive) checks.extend(extra_checks) clean_me = self._check_limits(_distdir, checks, clean_me) @@ -335,31 +336,30 @@ class DistfilesSearch: deprecated.update(_deprecated) return pkgs, deprecated - def vcs_check(self, distdir): + def vcs_check(self, distdir: Path) -> Set: """Checks $DISTDIR/vcs-src for checkouts which are not in the vardb""" # For now we only check git - vcs_src = os.path.join(distdir, "git3-src") - if not os.path.exists(vcs_src): - return {} - + vcs_src = distdir / "git3-src" expected_dirs = set() - for i in set(self.vardb.cpv_all()): - if "live" in self.vardb.aux_get(i, ["PROPERTIES"]): - try: - # try to get the dir names of the cloned - # repos from the environment file. - vcs_dir = { - i.split("=")[-1].strip('"') - for i in shlex.split( - self.vardb._aux_env_search(i, ["EVCS_STORE_DIRS"])[ - "EVCS_STORE_DIRS" - ].strip("()") - ) - } - expected_dirs.update(vcs_dir) - except KeyError: - pass - actual_dirs = {os.path.join(vcs_src, i) for i in os.listdir(vcs_src)} + actual_dirs = set() + if vcs_src.is_dir(): + for i in set(self.vardb.cpv_all()): + if "live" in self.vardb.aux_get(i, ["PROPERTIES"]): + try: + # try to get the dir names of the cloned + # repos from the environment file. + vcs_dir = { + i.split("=")[-1].strip('"') + for i in shlex.split( + self.vardb._aux_env_search(i, ["EVCS_STORE_DIRS"])[ + "EVCS_STORE_DIRS" + ].strip("()") + ) + } + expected_dirs.update(vcs_dir) + except KeyError: + pass + actual_dirs = {str(i) for i in vcs_src.iterdir() if i.is_dir()} return actual_dirs.difference(expected_dirs) def _fetch_restricted(self, pkgs_, cpvs): |