From: Michael Tremer Date: Wed, 1 Nov 2023 10:14:24 +0000 (+0000) Subject: _pakfire: Implement set_cache_path() X-Git-Tag: 0.9.30~1358 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bda8115c2db6ba9ecf8e5bd72c7ce3835e3896f8;p=pakfire.git _pakfire: Implement set_cache_path() Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/_pakfiremodule.c b/src/_pakfire/_pakfiremodule.c index 7f873ad04..af8b40e99 100644 --- a/src/_pakfire/_pakfiremodule.c +++ b/src/_pakfire/_pakfiremodule.c @@ -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,