]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Drop old cache stuff
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Mar 2021 18:25:53 +0000 (18:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Mar 2021 18:29:20 +0000 (18:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/_pakfire/repo.c
src/libpakfire/dist.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/include/pakfire/repo.h
src/libpakfire/libpakfire.sym
src/libpakfire/pakfire.c
src/libpakfire/repo.c

index 429c4938aed84fc1059aad09fe2dff8d486a16f1..be1ee0dc4c190b5efcc6dda49bf8566644b0d707 100644 (file)
@@ -143,23 +143,6 @@ static PyObject* Pakfire_get_repo(PakfireObject* self, PyObject* args) {
        return obj;
 }
 
-static PyObject* Pakfire_get_cache_path(PakfireObject* self) {
-       const char* path = pakfire_get_cache_path(self->pakfire);
-       if (!path)
-               Py_RETURN_NONE;
-
-       return PyUnicode_FromString(path);
-}
-
-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)
@@ -805,13 +788,6 @@ 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 cee9054c79658a4bbc12d74a70e2da4f11bbd494..9010480ce1fe112f6aeb937ea21cfb616b2393c3 100644 (file)
@@ -344,63 +344,6 @@ static PyObject* Repo_add_archive(RepoObject* self, PyObject* args) {
        return obj;
 }
 
-static PyObject* Repo_cache_age(RepoObject* self, PyObject* args) {
-       const char* path = NULL;
-
-       if (!PyArg_ParseTuple(args, "s", &path))
-               return NULL;
-
-       time_t age = pakfire_repo_cache_age(self->repo, path);
-       if (age < 0)
-               Py_RETURN_NONE;
-
-       return PyLong_FromLong(age);
-}
-
-static PyObject* Repo_cache_exists(RepoObject* self, PyObject* args) {
-       const char* path = NULL;
-
-       if (!PyArg_ParseTuple(args, "s", &path))
-               return NULL;
-
-       int r = pakfire_repo_cache_access(self->repo, path, F_OK);
-       if (r == 0)
-               Py_RETURN_TRUE;
-
-       Py_RETURN_FALSE;
-}
-
-static PyObject* Repo_cache_open(RepoObject* self, PyObject* args) {
-       const char* path = NULL;
-       const char* mode = NULL;
-
-       if (!PyArg_ParseTuple(args, "ss", &path, &mode))
-               return NULL;
-
-       FILE* f = pakfire_repo_cache_open(self->repo, path, mode);
-       if (!f) {
-               PyErr_Format(PyExc_IOError, "Could not open file %s: %s", path, strerror(errno));
-               return NULL;
-       }
-
-       // XXX might cause some problems with internal buffering
-       return PyFile_FromFd(fileno(f), NULL, mode, 1, NULL, NULL, NULL, 1);
-}
-
-static PyObject* Repo_cache_path(RepoObject* self, PyObject* args) {
-       const char* path = NULL;
-
-       if (!PyArg_ParseTuple(args, "s", &path))
-               return NULL;
-
-       char* cache_path = pakfire_repo_cache_get_path(self->repo, path);
-
-       PyObject* obj = PyUnicode_FromString(cache_path);
-       free(cache_path);
-
-       return obj;
-}
-
 static PyObject* Repo_clean(RepoObject* self, PyObject* args) {
        int r = pakfire_repo_clean(self->repo);
 
@@ -452,30 +395,6 @@ static struct PyMethodDef Repo_methods[] = {
                METH_VARARGS,
                NULL
        },
-       {
-               "cache_age",
-               (PyCFunction)Repo_cache_age,
-               METH_VARARGS,
-               NULL
-       },
-       {
-               "cache_exists",
-               (PyCFunction)Repo_cache_exists,
-               METH_VARARGS,
-               NULL
-       },
-       {
-               "cache_open",
-               (PyCFunction)Repo_cache_open,
-               METH_VARARGS,
-               NULL
-       },
-       {
-               "cache_path",
-               (PyCFunction)Repo_cache_path,
-               METH_VARARGS,
-               NULL
-       },
        {
                "clean",
                (PyCFunction)Repo_clean,
index f7c5f06bed095b87deca39d53874071a4080ef53..1f41640ce135d1554589441c2f7c748909a78488 100644 (file)
@@ -153,7 +153,7 @@ static int pakfire_dist_add_source(Pakfire pakfire, struct pakfire_packager* pac
 
        snprintf(archive_path, sizeof(archive_path) - 1, "files/%s", filename);
        snprintf(cache_path, sizeof(cache_path) - 1, "%s/sources/%s/%s",
-               pakfire_get_cache_path(pakfire), name, filename);
+               pakfire_make_cache_path(pakfire, ""), name, filename);
 
        // Download the file if it does not exist in the cache
        if (access(cache_path, R_OK) != 0) {
index 5ab5d6179087f12302e0c33d93c618500732cca9..afff55f79a39afa2f25f2f150a51ffde40c47e48 100644 (file)
@@ -56,16 +56,7 @@ void pakfire_set_installed_repo(Pakfire pakfire, PakfireRepo repo);
 PakfirePackageList pakfire_whatprovides(Pakfire pakfire, const char* provides, int flags);
 PakfirePackageList pakfire_search(Pakfire pakfire, const char* what, int flags);
 
-// Cache
-
-const char* pakfire_get_cache_path(Pakfire pakfire);
-void pakfire_set_cache_path(Pakfire pakfire, const char* path);
-
 int pakfire_cache_destroy(Pakfire pakfire, const char* path);
-int pakfire_cache_access(Pakfire pakfire, const char* path, int mode);
-int pakfire_cache_stat(Pakfire pakfire, const char* path, struct stat* buffer);
-time_t pakfire_cache_age(Pakfire pakfire, const char* path);
-FILE* pakfire_cache_open(Pakfire pakfire, const char* path, const char* flags);
 
 // Logging
 
index 7a8efc78f84672a8a2af065506f69139611c56e0..0297b1ec219cce9823410e3c50b014c93ce28d7f 100644 (file)
@@ -74,10 +74,6 @@ PakfirePackage pakfire_repo_add_archive(PakfireRepo repo, PakfireArchive archive
 // Cache
 
 int pakfire_repo_clean(PakfireRepo repo);
-char* pakfire_repo_cache_get_path(PakfireRepo repo, const char* path);
-FILE* pakfire_repo_cache_open(PakfireRepo repo, const char* path, const char* mode);
-int pakfire_repo_cache_access(PakfireRepo repo, const char* path, int mode);
-time_t pakfire_repo_cache_age(PakfireRepo repo, const char* path);
 
 // Scan
 
index 200719a2c4718b6ec55610f87b5d54f4cb35a339..5790240f040a71ad2df55a5a65bed43dd1b755bb 100644 (file)
@@ -22,8 +22,6 @@ LIBPAKFIRE_0 {
 global:
        # pakfire
        pakfire_activate;
-       pakfire_cache_age;
-       pakfire_cache_stat;
        pakfire_count_packages;
        pakfire_create;
        pakfire_deactivate;
@@ -31,7 +29,6 @@ global:
        pakfire_execute_command;
        pakfire_execute_script;
        pakfire_get_arch;
-       pakfire_get_cache_path;
        pakfire_get_installed_repo;
        pakfire_get_installonly;
        pakfire_get_path;
@@ -42,7 +39,6 @@ global:
        pakfire_read_makefile;
        pakfire_ref;
        pakfire_search;
-       pakfire_set_cache_path;
        pakfire_set_installed_repo;
        pakfire_set_installonly;
        pakfire_unref;
@@ -291,16 +287,11 @@ global:
 
        # repo
        pakfire_repo_add_archive;
-       pakfire_repo_cache_access;
-       pakfire_repo_cache_age;
-       pakfire_repo_cache_get_path;
-       pakfire_repo_cache_open;
        pakfire_repo_cmp;
        pakfire_repo_count;
        pakfire_repo_clean;
        pakfire_repo_create;
        pakfire_repo_get_baseurl;
-       pakfire_repo_get_cache;
        pakfire_repo_get_config;
        pakfire_repo_get_description;
        pakfire_repo_get_name;
index a5eb1f0150dcfd488a08287e650bbaa813a846e2..87260978c21ba1d6f4fe554555bfdf24b555bc49 100644 (file)
@@ -176,6 +176,9 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char
        // Set path
        snprintf(p->path, sizeof(p->path) - 1, "%s", path);
 
+       // Set cache path
+       snprintf(p->cache_path, sizeof(p->cache_path) - 1, "%s", CACHE_PATH);
+
        // Set architecture
        snprintf(p->arch, sizeof(p->arch) - 1, "%s", arch);
 
@@ -206,9 +209,6 @@ PAKFIRE_EXPORT int pakfire_create(Pakfire* pakfire, const char* path, const char
        if (r)
                goto ERROR;
 
-       // Initialise cache
-       pakfire_set_cache_path(p, CACHE_PATH);
-
        *pakfire = p;
 
        return 0;
@@ -651,16 +651,6 @@ PAKFIRE_EXPORT PakfirePackageList pakfire_search(Pakfire pakfire, const char* wh
 
 // Cache
 
-PAKFIRE_EXPORT const char* pakfire_get_cache_path(Pakfire pakfire) {
-       return pakfire->cache_path;
-}
-
-PAKFIRE_EXPORT void pakfire_set_cache_path(Pakfire pakfire, const char* path) {
-       DEBUG(pakfire, "Setting cache path to %s\n", path);
-
-       snprintf(pakfire->cache_path, sizeof(pakfire->cache_path) - 1, "%s", path);
-}
-
 PAKFIRE_EXPORT char* pakfire_make_cache_path(Pakfire pakfire, const char* format, ...) {
        char path[PATH_MAX];
        va_list args;
@@ -691,60 +681,6 @@ PAKFIRE_EXPORT int pakfire_cache_destroy(Pakfire pakfire, const char* path) {
        return r;
 }
 
-PAKFIRE_EXPORT int pakfire_cache_stat(Pakfire pakfire, const char* path, struct stat* buffer) {
-       char* cache_path = pakfire_make_cache_path(pakfire, path);
-
-       int r = stat(cache_path, buffer);
-       free(cache_path);
-
-       return r;
-}
-
-PAKFIRE_EXPORT int pakfire_cache_access(Pakfire pakfire, const char* path, int mode) {
-       char* cache_path = pakfire_make_cache_path(pakfire, path);
-
-       int r = pakfire_access(pakfire, cache_path, NULL, mode);
-       free(cache_path);
-
-       return r;
-}
-
-PAKFIRE_EXPORT time_t pakfire_cache_age(Pakfire pakfire, const char* path) {
-       struct stat buffer;
-
-       int r = pakfire_cache_stat(pakfire, path, &buffer);
-       if (r == 0) {
-               // Get current timestamp
-               time_t now = time(NULL);
-
-               // Calculate the difference since the file has been created and now.
-               return now - buffer.st_ctime;
-       }
-
-       return -1;
-}
-
-PAKFIRE_EXPORT FILE* pakfire_cache_open(Pakfire pakfire, const char* path, const char* flags) {
-       FILE* f = NULL;
-       char* cache_path = pakfire_make_cache_path(pakfire, path);
-
-       // Ensure that the parent directory exists
-       char* cache_dirname = pakfire_dirname(cache_path);
-
-       int r = pakfire_mkdir(pakfire, cache_dirname, S_IRUSR|S_IWUSR|S_IXUSR);
-       if (r)
-               goto FAIL;
-
-       // Open the file
-       f = fopen(cache_path, flags);
-
-FAIL:
-       free(cache_path);
-       free(cache_dirname);
-
-       return f;
-}
-
 PAKFIRE_EXPORT pakfire_log_function_t pakfire_log_get_function(Pakfire pakfire) {
        return pakfire->log_function;
 }
index 945b1952ed96486806a07ca4669d29ab972be808..4120d6ffaa693afbaa200439ece6954fecff512b 100644 (file)
@@ -836,28 +836,8 @@ PAKFIRE_EXPORT PakfirePackage pakfire_repo_add_archive(PakfireRepo repo, Pakfire
        return pakfire_archive_make_package(archive, repo);
 }
 
-// Cache
-
-static char* pakfire_repo_get_cache_prefix(PakfireRepo repo) {
-       char* prefix = calloc(1, STRING_SIZE + 1);
-
-       snprintf(prefix, STRING_SIZE, "repodata/%s", pakfire_repo_get_name(repo));
-
-       return prefix;
-}
-
-static char* pakfire_repo_make_cache_path(PakfireRepo repo, const char* path) {
-       char* prefix = pakfire_repo_get_cache_prefix(repo);
-
-       // Add the prefix for the repository first
-       char* cache_path = pakfire_path_join(prefix, path);
-       free(prefix);
-
-       return cache_path;
-}
-
 PAKFIRE_EXPORT int pakfire_repo_clean(PakfireRepo repo) {
-       char* cache_path = pakfire_repo_make_cache_path(repo, NULL);
+       char* cache_path = pakfire_make_cache_path(repo->pakfire, pakfire_repo_get_name(repo));
 
        if (cache_path)
                return pakfire_cache_destroy(repo->pakfire, cache_path);
@@ -865,42 +845,6 @@ PAKFIRE_EXPORT int pakfire_repo_clean(PakfireRepo repo) {
        return -1;
 }
 
-PAKFIRE_EXPORT char* pakfire_repo_cache_get_path(PakfireRepo repo, const char* path) {
-       char* repo_cache_path = pakfire_repo_make_cache_path(repo, path);
-
-       char* cache_path = pakfire_make_cache_path(repo->pakfire, repo_cache_path);
-       free(repo_cache_path);
-
-       return cache_path;
-}
-
-PAKFIRE_EXPORT FILE* pakfire_repo_cache_open(PakfireRepo repo, const char* path, const char* mode) {
-       char* cache_path = pakfire_repo_make_cache_path(repo, path);
-
-       FILE* f = pakfire_cache_open(repo->pakfire, cache_path, mode);
-       free(cache_path);
-
-       return f;
-}
-
-PAKFIRE_EXPORT int pakfire_repo_cache_access(PakfireRepo repo, const char* path, int mode) {
-       char* cache_path = pakfire_repo_make_cache_path(repo, path);
-
-       int r = pakfire_cache_access(repo->pakfire, cache_path, mode);
-       free(cache_path);
-
-       return r;
-}
-
-PAKFIRE_EXPORT time_t pakfire_repo_cache_age(PakfireRepo repo, const char* path) {
-       char* cache_path = pakfire_repo_make_cache_path(repo, path);
-
-       time_t t = pakfire_cache_age(repo->pakfire, cache_path);
-       free(cache_path);
-
-       return t;
-}
-
 static int pakfire_repo_scan_file(PakfireRepo repo, const char* path) {
        PakfireArchive archive = pakfire_archive_open(repo->pakfire, path);
        if (!archive)