From: Michael Tremer Date: Fri, 19 Jan 2018 12:10:13 +0000 (+0100) Subject: libpakfire: Remove cache path from Pool X-Git-Tag: 0.9.28~1285^2~1163 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b31be147d6052e64cd1d07dd91c88728a849bfb5;p=pakfire.git libpakfire: Remove cache path from Pool Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index 6fbde87de..09aa2600b 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "key.h" #include "pakfire.h" @@ -78,6 +79,26 @@ static PyObject* Pakfire_get_arch(PakfireObject* self) { return PyUnicode_FromString(arch); } +static PyObject* Pakfire_get_cache_path(PakfireObject* self) { + char* path = pakfire_get_cache_path(self->pakfire, NULL); + if (!path) + Py_RETURN_NONE; + + PyObject* obj = PyUnicode_FromString(path); + pakfire_free(path); + + return obj; +} + +static int Pakfire_set_cache_path(PakfireObject* self, PyObject* value) { + const char* path = PyUnicode_AsUTF8(value); + + if (path) + pakfire_set_cache_path(self->pakfire, path); + + return 0; +} + static PyObject* Pakfire_get_installed_repo(PakfireObject* self) { PakfireRepo repo = pakfire_get_installed_repo(self->pakfire); if (!repo) @@ -308,6 +329,13 @@ static struct PyGetSetDef Pakfire_getsetters[] = { NULL, NULL }, + { + "cache_path", + (getter)Pakfire_get_cache_path, + (setter)Pakfire_set_cache_path, + NULL, + NULL + }, { "installed_repo", (getter)Pakfire_get_installed_repo, diff --git a/src/_pakfire/pool.c b/src/_pakfire/pool.c index e92539336..83fde724e 100644 --- a/src/_pakfire/pool.c +++ b/src/_pakfire/pool.c @@ -63,33 +63,6 @@ static int Pool_init(PoolObject* self, PyObject* args, PyObject* kwds) { return 0; } -static PyObject* Pool_get_cache_path(PoolObject* self) { - const char* path = pakfire_pool_get_cache_path(self->pool); - if (!path) - Py_RETURN_NONE; - - return PyUnicode_FromString(path); -} - -static int Pool_set_cache_path(PoolObject* self, PyObject* value) { - const char* path = PyUnicode_AsUTF8(value); - assert(path); - - pakfire_pool_set_cache_path(self->pool, path); - return 0; -} - -static struct PyGetSetDef Pool_getsetters[] = { - { - "cache_path", - (getter)Pool_get_cache_path, - (setter)Pool_set_cache_path, - NULL, - NULL - }, - { NULL } -}; - PyTypeObject PoolType = { PyVarObject_HEAD_INIT(NULL, 0) tp_name: "_pakfire.Pool", @@ -99,5 +72,4 @@ PyTypeObject PoolType = { tp_dealloc: (destructor)Pool_dealloc, tp_init: (initproc)Pool_init, tp_doc: "Pool object", - tp_getset: Pool_getsetters, }; diff --git a/src/libpakfire/include/pakfire/pool.h b/src/libpakfire/include/pakfire/pool.h index 6e34f873f..b864d2397 100644 --- a/src/libpakfire/include/pakfire/pool.h +++ b/src/libpakfire/include/pakfire/pool.h @@ -28,8 +28,6 @@ PakfirePool pakfire_pool_create(Pakfire pakfire); PakfirePool pakfire_pool_ref(PakfirePool pool); PakfirePool pakfire_pool_unref(PakfirePool pool); -const char* pakfire_pool_get_cache_path(PakfirePool pool); -void pakfire_pool_set_cache_path(PakfirePool pool, const char* path); PakfireCache pakfire_pool_get_cache(PakfirePool pool); #ifdef PAKFIRE_PRIVATE diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 863321401..7039c518c 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -206,9 +206,7 @@ global: # pool pakfire_pool_create; - pakfire_pool_get_cache_path; pakfire_pool_ref; - pakfire_pool_set_cache_path; pakfire_pool_unref; # problem diff --git a/src/libpakfire/pool.c b/src/libpakfire/pool.c index 4e78f3bd1..aae9920cf 100644 --- a/src/libpakfire/pool.c +++ b/src/libpakfire/pool.c @@ -83,20 +83,6 @@ Pool* pakfire_pool_get_solv_pool(PakfirePool pool) { return pakfire_get_solv_pool(pool->pakfire); } -PAKFIRE_EXPORT const char* pakfire_pool_get_cache_path(PakfirePool pool) { - if (!pool->cache) - return NULL; - - return pakfire_cache_get_path(pool->cache); -} - -PAKFIRE_EXPORT void pakfire_pool_set_cache_path(PakfirePool pool, const char* path) { - if (pool->cache) - pakfire_cache_free(pool->cache); - - pool->cache = pakfire_cache_create(pool, path); -} - PAKFIRE_EXPORT PakfireCache pakfire_pool_get_cache(PakfirePool pool) { if (pool->cache) return pool->cache; diff --git a/src/pakfire/base.py b/src/pakfire/base.py index adeccdfff..e4bf75751 100644 --- a/src/pakfire/base.py +++ b/src/pakfire/base.py @@ -60,7 +60,7 @@ class Pakfire(_pakfire.Pakfire): self.config = config or Config("general.conf") self.pool = _pakfire.Pool(self) - self.pool.cache_path = cache_path or \ + self.cache_path = cache_path or \ os.path.join(CACHE_DIR, self.distro.sname, self.distro.release) self.repos = repository.Repositories(self)