]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Remove cache path from Pool
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Jan 2018 12:10:13 +0000 (13:10 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Jan 2018 12:10:13 +0000 (13:10 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/_pakfire/pool.c
src/libpakfire/include/pakfire/pool.h
src/libpakfire/libpakfire.sym
src/libpakfire/pool.c
src/pakfire/base.py

index 6fbde87de1b1262d71732b40a38e843d3160c5c0..09aa2600baa31b5b10209726c5bb5abe835c1289 100644 (file)
@@ -23,6 +23,7 @@
 #include <pakfire/pakfire.h>
 #include <pakfire/key.h>
 #include <pakfire/repo.h>
+#include <pakfire/util.h>
 
 #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,
index e92539336c0411c8dec40cf58466addb8a41c04b..83fde724e512857618affb7dd2addf1f042644ad 100644 (file)
@@ -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,
 };
index 6e34f873fa187733ffaa56ee27f458847af12482..b864d2397a245e50baa2435b902ad1fbd908adb9 100644 (file)
@@ -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
index 863321401ba9490f909bb3de6c8e2cf4e67c7f26..7039c518cf838270642de29732b2e345e3773b06 100644 (file)
@@ -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
index 4e78f3bd16268c993c807e409c46caa671a08a18..aae9920cfab6962957447d22b5a24d3a924d3d53 100644 (file)
@@ -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;
index adeccdfff81e5b3fd6f9b9da676425f9845c59a4..e4bf7575148482675468d785ebcbe17354a543d4 100644 (file)
@@ -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)