From: Michael Tremer Date: Fri, 16 Feb 2018 13:39:41 +0000 (+0100) Subject: Fix cleaning repositories X-Git-Tag: 0.9.28~1285^2~1119 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb6d631c23ab7cc009e936105b3313b524641ecb;p=pakfire.git Fix cleaning repositories It is okay if the file does not exist. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 8deb26e2f..9859bb251 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -18,6 +18,7 @@ # # #############################################################################*/ +#include #include #include #include @@ -340,6 +341,10 @@ PAKFIRE_EXPORT int pakfire_cache_destroy(Pakfire pakfire, const char* path) { int r = nftw(cache_path, _unlink, 64, FTW_DEPTH|FTW_PHYS); pakfire_free(cache_path); + // It is okay if the path doesn't exist + if (r < 0 && errno == ENOENT) + r = 0; + return r; } diff --git a/src/pakfire/base.py b/src/pakfire/base.py index f0b6b824e..b87520e59 100644 --- a/src/pakfire/base.py +++ b/src/pakfire/base.py @@ -125,10 +125,9 @@ class Pakfire(_pakfire.Pakfire): raise NotAnIPFireSystemError("You can run pakfire only on an IPFire system") def clean(self): - log.debug("Cleaning up everything...") - - # Clean up repository caches. - self.repos.clean() + # Clean up repository caches + for repo in self.repos: + repo.clean() def build(self, makefile, resultdir, stages=None, **kwargs): b = builder.Builder(self, makefile, resultdir, **kwargs) diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index 4b76d2779..388774ec2 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -361,10 +361,10 @@ class Cli(object): print(FORMAT % (repo.name, repo.enabled, repo.priority, len(repo))) def handle_clean(self, ns): - print(_("Cleaning up everything...")) + self.ui.message(_("Cleaning up everything...")) - with self.pakfire(ns) as p: - p.clean() + p = self.pakfire(ns) + p.clean() def handle_check(self, ns): with self.pakfire(ns) as p: