From: Michael Tremer Date: Sat, 19 Jun 2021 13:04:18 +0000 (+0000) Subject: Add flags to clean function for better extensibility X-Git-Tag: 0.9.28~1224 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=119ec3cf6dc12cb8209edb567f55dac9369b25bf;p=pakfire.git Add flags to clean function for better extensibility Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index c8e17fab1..ca62a9bf1 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -850,7 +850,7 @@ static PyObject* Pakfire_shell(PakfireObject* self) { } static PyObject* Pakfire_clean(PakfireObject* self) { - int r = pakfire_clean(self->pakfire); + int r = pakfire_clean(self->pakfire, 0); if (r) { PyErr_SetFromErrno(PyExc_OSError); return NULL; diff --git a/src/_pakfire/repo.c b/src/_pakfire/repo.c index fc22ceb4b..e592c8dad 100644 --- a/src/_pakfire/repo.c +++ b/src/_pakfire/repo.c @@ -311,7 +311,7 @@ static PyObject* Repo_add_archive(RepoObject* self, PyObject* args) { } static PyObject* Repo_clean(RepoObject* self, PyObject* args) { - int r = pakfire_repo_clean(self->repo); + int r = pakfire_repo_clean(self->repo, 0); if (r) { PyErr_SetFromErrno(PyExc_OSError); @@ -352,7 +352,7 @@ static PyObject* Repo_exit(RepoObject* self, PyObject* args) { // Automatically cleanup the repository if (self->clean) { - int r = pakfire_repo_clean(self->repo); + int r = pakfire_repo_clean(self->repo, 0); if (r) { PyErr_SetFromErrno(PyExc_OSError); diff --git a/src/libpakfire/include/pakfire/pakfire.h b/src/libpakfire/include/pakfire/pakfire.h index dfbcb9dc7..f286384ec 100644 --- a/src/libpakfire/include/pakfire/pakfire.h +++ b/src/libpakfire/include/pakfire/pakfire.h @@ -47,7 +47,7 @@ Pakfire pakfire_unref(Pakfire pakfire); const char* pakfire_get_path(Pakfire pakfire); -int pakfire_clean(Pakfire pakfire); +int pakfire_clean(Pakfire pakfire, int flags); int pakfire_bind(Pakfire pakfire, const char* src, const char* dst, int flags); diff --git a/src/libpakfire/include/pakfire/repo.h b/src/libpakfire/include/pakfire/repo.h index 2020944ad..3cd59424f 100644 --- a/src/libpakfire/include/pakfire/repo.h +++ b/src/libpakfire/include/pakfire/repo.h @@ -75,7 +75,7 @@ PakfirePackage pakfire_repo_add_archive(PakfireRepo repo, PakfireArchive archive // Cache -int pakfire_repo_clean(PakfireRepo repo); +int pakfire_repo_clean(PakfireRepo repo, int flags); // Scan diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 9f91b8101..f6ffb8dbe 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -1053,7 +1053,8 @@ PAKFIRE_EXPORT int pakfire_bind(Pakfire pakfire, const char* src, const char* ds return __mount(pakfire, src, mountpoint, NULL, flags|MS_BIND, NULL); } -static int pakfire_foreach_repo(Pakfire pakfire, int (*func)(PakfireRepo repo)) { +static int pakfire_foreach_repo(Pakfire pakfire, + int (*func)(PakfireRepo repo, int flags), int flags) { PakfireRepo repo; Repo* solv_repo; @@ -1069,7 +1070,7 @@ static int pakfire_foreach_repo(Pakfire pakfire, int (*func)(PakfireRepo repo)) return 1; // Run callback - r = func(repo); + r = func(repo, flags); pakfire_repo_unref(repo); // Raise any errors @@ -1080,8 +1081,8 @@ static int pakfire_foreach_repo(Pakfire pakfire, int (*func)(PakfireRepo repo)) return 0; } -PAKFIRE_EXPORT int pakfire_clean(Pakfire pakfire) { - return pakfire_foreach_repo(pakfire, pakfire_repo_clean); +PAKFIRE_EXPORT int pakfire_clean(Pakfire pakfire, int flags) { + return pakfire_foreach_repo(pakfire, pakfire_repo_clean, flags); } static int pakfire_copy(Pakfire pakfire, const char* src, const char* dst) { diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index ad3b8c50f..3ce328c3e 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -804,7 +804,7 @@ PAKFIRE_EXPORT PakfirePackage pakfire_repo_add_archive(PakfireRepo repo, Pakfire return pakfire_archive_make_package(archive, repo); } -PAKFIRE_EXPORT int pakfire_repo_clean(PakfireRepo repo) { +PAKFIRE_EXPORT int pakfire_repo_clean(PakfireRepo repo, int flags) { char cache_path[PATH_MAX]; // Drop all meta-data from memory