From: Michael Tremer Date: Sat, 19 Jun 2021 12:44:19 +0000 (+0000) Subject: libpakfire: Add helper function that calls a method for each repo X-Git-Tag: 0.9.28~1225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=640e0dd0f070c5c6e2093e34733c04abd60e2f06;p=pakfire.git libpakfire: Add helper function that calls a method for each repo Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index e6c4bcb50..9f91b8101 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -1053,22 +1053,23 @@ PAKFIRE_EXPORT int pakfire_bind(Pakfire pakfire, const char* src, const char* ds return __mount(pakfire, src, mountpoint, NULL, flags|MS_BIND, NULL); } -PAKFIRE_EXPORT int pakfire_clean(Pakfire pakfire) { +static int pakfire_foreach_repo(Pakfire pakfire, int (*func)(PakfireRepo repo)) { PakfireRepo repo; + Repo* solv_repo; int i; int r; Pool* pool = pakfire->pool; - // Cleanup all repositories + // Run func for every repository FOR_REPOS(i, solv_repo) { repo = pakfire_repo_create_from_repo(pakfire, solv_repo); if (!repo) return 1; - // Perform cleanup - r = pakfire_repo_clean(repo); + // Run callback + r = func(repo); pakfire_repo_unref(repo); // Raise any errors @@ -1079,6 +1080,10 @@ PAKFIRE_EXPORT int pakfire_clean(Pakfire pakfire) { return 0; } +PAKFIRE_EXPORT int pakfire_clean(Pakfire pakfire) { + return pakfire_foreach_repo(pakfire, pakfire_repo_clean); +} + static int pakfire_copy(Pakfire pakfire, const char* src, const char* dst) { char buffer[512 * 1024]; struct archive* reader = NULL;