]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
_pakfire: Implement set_cache_path()
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 10:14:24 +0000 (10:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 10:14:24 +0000 (10:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/_pakfiremodule.c

index 7f873ad0429e909feceb682936a5b569c1337e9a..af8b40e997df7e9c921ef192d391ecde63be5d8a 100644 (file)
@@ -180,6 +180,25 @@ CLEANUP:
        return r;
 }
 
+static PyObject* _pakfire_set_cache_path(PyObject* self, PyObject* args) {
+       const char* path = NULL;
+       int r;
+
+       if (!PyArg_ParseTuple(args, "s", &path))
+               return NULL;
+
+       // Set the cache path
+       r = pakfire_ctx_set_cache_path(pakfire_ctx, path);
+       if (r) {
+               errno = -r;
+               PyErr_SetFromErrno(PyExc_OSError);
+
+               return NULL;
+       }
+
+       Py_RETURN_NONE;
+}
+
 static PyObject* _pakfire_set_log_level(PyObject* self, PyObject* args) {
        int level = 0;
 
@@ -246,6 +265,12 @@ static PyObject* _pakfire_version_compare(PyObject* self, PyObject* args) {
 }
 
 static PyMethodDef pakfireModuleMethods[] = {
+       {
+               "set_cache_path",
+               (PyCFunction)_pakfire_set_cache_path,
+               METH_VARARGS,
+               NULL,
+       },
        {
                "set_log_level",
                (PyCFunction)_pakfire_set_log_level,