]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Drop repocache
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Jan 2018 13:20:44 +0000 (14:20 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Jan 2018 13:20:44 +0000 (14:20 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/_pakfire/repo.c
src/libpakfire/include/pakfire/repo.h
src/libpakfire/include/pakfire/repocache.h [deleted file]
src/libpakfire/libpakfire.sym
src/libpakfire/package.c
src/libpakfire/repo.c
src/libpakfire/repocache.c [deleted file]

index b64a95a035fb10932887f3168aae83d6cf8a4623..cfe38bf9358182dcb756469026577009cd43dd4c 100644 (file)
@@ -260,7 +260,6 @@ libpakfire_la_SOURCES = \
        src/libpakfire/relation.c \
        src/libpakfire/relationlist.c \
        src/libpakfire/repo.c \
-       src/libpakfire/repocache.c \
        src/libpakfire/request.c \
        src/libpakfire/selector.c \
        src/libpakfire/solution.c \
@@ -288,7 +287,6 @@ pkginclude_HEADERS += \
        src/libpakfire/include/pakfire/relation.h \
        src/libpakfire/include/pakfire/relationlist.h \
        src/libpakfire/include/pakfire/repo.h \
-       src/libpakfire/include/pakfire/repocache.h \
        src/libpakfire/include/pakfire/request.h \
        src/libpakfire/include/pakfire/selector.h \
        src/libpakfire/include/pakfire/solution.h \
index 9d96cc3f73ae44931fb8fd0279fa7de9b849d9bc..48b17e74ccc6bd7c5b4a05bb191d8edda2266716 100644 (file)
@@ -23,7 +23,6 @@
 #include <pakfire/errno.h>
 #include <pakfire/package.h>
 #include <pakfire/repo.h>
-#include <pakfire/repocache.h>
 #include <pakfire/util.h>
 
 #include "package.h"
@@ -226,74 +225,55 @@ static PyObject* Repo__add_package(RepoObject* self, PyObject* args) {
 }
 
 static PyObject* Repo_cache_age(RepoObject* self, PyObject* args) {
-       const char* filename = NULL;
+       const char* path = NULL;
 
-       if (!PyArg_ParseTuple(args, "s", &filename))
+       if (!PyArg_ParseTuple(args, "s", &path))
                return NULL;
 
-       PakfireRepoCache cache = pakfire_repo_get_cache(self->repo);
-       if (!cache)
-               Py_RETURN_NONE;
-
-       int age = pakfire_repocache_age(cache, filename);
-
+       time_t age = pakfire_repo_cache_age(self->repo, path);
        if (age < 0)
                Py_RETURN_NONE;
 
-       PyObject* ret = PyLong_FromLong(age);
-       return ret;
+       return PyLong_FromLong(age);
 }
 
 static PyObject* Repo_cache_exists(RepoObject* self, PyObject* args) {
-       const char* filename = NULL;
+       const char* path = NULL;
 
-       if (!PyArg_ParseTuple(args, "s", &filename))
+       if (!PyArg_ParseTuple(args, "s", &path))
                return NULL;
 
-       PakfireRepoCache cache = pakfire_repo_get_cache(self->repo);
-       if (!cache)
-               Py_RETURN_NONE;
-
-       int ret = pakfire_repocache_has_file(cache, filename);
-
-       if (ret)
+       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* filename = NULL;
-       char* mode = NULL;
+       const char* path = NULL;
+       const char* mode = NULL;
 
-       if (!PyArg_ParseTuple(args, "ss", &filename, &mode))
+       if (!PyArg_ParseTuple(args, "ss", &path, &mode))
                return NULL;
 
-       PakfireRepoCache cache = pakfire_repo_get_cache(self->repo);
-       if (!cache)
-               Py_RETURN_NONE;
-
-       FILE* fp = pakfire_repocache_open(cache, filename, mode);
-       if (!fp) {
-               PyErr_Format(PyExc_IOError, "Could not open file %s: %s", filename, strerror(errno));
+       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(fp), NULL, mode, 1, NULL, NULL, NULL, 1);
+       return PyFile_FromFd(fileno(f), NULL, mode, 1, NULL, NULL, NULL, 1);
 }
 
 static PyObject* Repo_cache_path(RepoObject* self, PyObject* args) {
-       const char* filename = NULL;
+       const char* path = NULL;
 
-       if (!PyArg_ParseTuple(args, "s", &filename))
+       if (!PyArg_ParseTuple(args, "s", &path))
                return NULL;
 
-       PakfireRepoCache cache = pakfire_repo_get_cache(self->repo);
-       if (!cache)
-               Py_RETURN_NONE;
-
-       char* cache_path = pakfire_repocache_get_full_path(cache, filename);
+       char* cache_path = pakfire_repo_cache_get_path(self->repo, path);
 
        PyObject* obj = PyUnicode_FromString(cache_path);
        pakfire_free(cache_path);
index baf985205da75c4713a82348c17ff79eb86a6590..d65b83b67c7f633d517a82c92ead02959ef7b996 100644 (file)
@@ -21,6 +21,9 @@
 #ifndef PAKFIRE_REPO_H
 #define PAKFIRE_REPO_H
 
+#include <time.h>
+#include <unistd.h>
+
 #include <pakfire/types.h>
 
 PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name);
@@ -53,9 +56,13 @@ int pakfire_repo_read_solv_fp(PakfireRepo repo, FILE *f, int flags);
 int pakfire_repo_write_solv(PakfireRepo repo, const char* filename, int flags);
 int pakfire_repo_write_solv_fp(PakfireRepo repo, FILE *f, int flags);
 
-PakfireRepoCache pakfire_repo_get_cache(PakfireRepo repo);
+// 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);
 
 #ifdef PAKFIRE_PRIVATE
 
diff --git a/src/libpakfire/include/pakfire/repocache.h b/src/libpakfire/include/pakfire/repocache.h
deleted file mode 100644 (file)
index 02f5307..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*#############################################################################
-#                                                                             #
-# Pakfire - The IPFire package management system                              #
-# Copyright (C) 2013 Pakfire development team                                 #
-#                                                                             #
-# This program is free software: you can redistribute it and/or modify        #
-# it under the terms of the GNU General Public License as published by        #
-# the Free Software Foundation, either version 3 of the License, or           #
-# (at your option) any later version.                                         #
-#                                                                             #
-# This program is distributed in the hope that it will be useful,             #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
-# GNU General Public License for more details.                                #
-#                                                                             #
-# You should have received a copy of the GNU General Public License           #
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
-#                                                                             #
-#############################################################################*/
-
-#ifndef PAKFIRE_REPOCACHE_H
-#define PAKFIRE_REPOCACHE_H
-
-#include <stdio.h>
-
-#include <pakfire/types.h>
-
-PakfireRepoCache pakfire_repocache_create(PakfireRepo repo);
-void pakfire_repocache_free(PakfireRepoCache repo_cache);
-
-char* pakfire_repocache_get_cache_path(PakfireRepoCache repo_cache, const char* path);
-char* pakfire_repocache_get_full_path(PakfireRepoCache repo_cache, const char* path);
-
-int pakfire_repocache_has_file(PakfireRepoCache repo_cache, const char* filename);
-int pakfire_repocache_age(PakfireRepoCache repo_cache, const char* filename);
-
-FILE* pakfire_repocache_open(PakfireRepoCache repo_cache, const char* filename, const char* flags);
-
-int pakfire_repocache_destroy(PakfireRepoCache repo_cache);
-
-#ifdef PAKFIRE_PRIVATE
-
-struct _PakfireRepoCache {
-       PakfireRepo repo;
-       char* prefix;
-};
-
-inline PakfirePool pakfire_repocache_pool(PakfireRepoCache repo_cache) {
-       return pakfire_repo_get_pool(repo_cache->repo);
-}
-
-inline PakfireCache pakfire_repocache_cache(PakfireRepoCache repo_cache) {
-       PakfirePool pool = pakfire_repocache_pool(repo_cache);
-
-       return pakfire_pool_get_cache(pool);
-}
-
-#endif
-
-#endif /* PAKFIRE_REPOCACHE_H */
index 9dbb252dab068540ad69ef22cd1d740f3045e485..5c7db0be76341d59a75cca14d0d443e364d3b5e2 100644 (file)
@@ -220,6 +220,10 @@ global:
        pakfire_problem_unref;
 
        # repo
+       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;
@@ -243,16 +247,6 @@ global:
        pakfire_repo_write_solv_fp;
        pakfire_repo_unref;
 
-       # repocache
-       pakfire_repocache_age;
-       pakfire_repocache_create;
-       pakfire_repocache_destroy;
-       pakfire_repocache_free;
-       pakfire_repocache_get_cache_path;
-       pakfire_repocache_get_full_path;
-       pakfire_repocache_has_file;
-       pakfire_repocache_open;
-
        # relation
        pakfire_relation_create;
        pakfire_relation_create_from_id;
index 1b3e9e416455cc74a0fc79531fa89790635a901f..19a4ad9269485a723c134cfdf7be88136d052ace 100644 (file)
@@ -43,7 +43,6 @@
 #include <pakfire/relation.h>
 #include <pakfire/relationlist.h>
 #include <pakfire/repo.h>
-#include <pakfire/repocache.h>
 #include <pakfire/util.h>
 
 struct _PakfirePackage {
index d1104088db006d2016c454111326c85ab8bcf455..0220fc089ebe71491b00eb5ec793c3c39df10f45 100644 (file)
@@ -37,7 +37,6 @@
 #include <pakfire/pool.h>
 #include <pakfire/private.h>
 #include <pakfire/repo.h>
-#include <pakfire/repocache.h>
 #include <pakfire/types.h>
 #include <pakfire/util.h>
 
@@ -47,7 +46,6 @@ const size_t XZ_HEADER_LENGTH = sizeof(XZ_HEADER_MAGIC);
 struct _PakfireRepo {
        Pakfire pakfire;
        Repo* repo;
-       PakfireRepoCache cache;
        Repodata* filelist;
        int nrefs;
 };
@@ -109,7 +107,6 @@ PAKFIRE_EXPORT PakfireRepo pakfire_repo_create_from_repo(Pakfire pakfire, Repo*
 
                repo->pakfire = pakfire_ref(pakfire);
                repo->repo = r;
-               repo->cache = pakfire_repocache_create(repo);
 
                repo->filelist = repo_add_repodata(r,
                        REPO_EXTEND_SOLVABLES|REPO_LOCALPOOL|REPO_NO_INTERNALIZE|REPO_NO_LOCATION);
@@ -128,9 +125,6 @@ static void pakfire_repo_free(PakfireRepo repo) {
        if (repo->repo)
                repo->repo->appdata = NULL;
 
-       if (repo->cache)
-               pakfire_repocache_free(repo->cache);
-
        pakfire_unref(repo->pakfire);
 
        pakfire_free(repo);
@@ -430,11 +424,7 @@ PAKFIRE_EXPORT PakfirePackage pakfire_repo_add_package(PakfireRepo repo) {
        return pakfire_package_create(repo->pakfire, id);
 }
 
-PAKFIRE_EXPORT PakfireRepoCache pakfire_repo_get_cache(PakfireRepo repo) {
-       assert(repo);
-
-       return repo->cache;
-}
+// Cache
 
 static char* pakfire_repo_get_cache_prefix(PakfireRepo repo) {
        char* prefix = pakfire_calloc(1, STRING_SIZE + 1);
@@ -462,3 +452,39 @@ 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_get_cache_path(repo->pakfire, repo_cache_path);
+       pakfire_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);
+       pakfire_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);
+       pakfire_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);
+       pakfire_free(cache_path);
+
+       return t;
+}
diff --git a/src/libpakfire/repocache.c b/src/libpakfire/repocache.c
deleted file mode 100644 (file)
index 9bc1b8c..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*#############################################################################
-#                                                                             #
-# Pakfire - The IPFire package management system                              #
-# Copyright (C) 2013 Pakfire development team                                 #
-#                                                                             #
-# This program is free software: you can redistribute it and/or modify        #
-# it under the terms of the GNU General Public License as published by        #
-# the Free Software Foundation, either version 3 of the License, or           #
-# (at your option) any later version.                                         #
-#                                                                             #
-# This program is distributed in the hope that it will be useful,             #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
-# GNU General Public License for more details.                                #
-#                                                                             #
-# You should have received a copy of the GNU General Public License           #
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
-#                                                                             #
-#############################################################################*/
-
-#define _XOPEN_SOURCE 500
-#include <ftw.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include <pakfire/cache.h>
-#include <pakfire/constants.h>
-#include <pakfire/package.h>
-#include <pakfire/private.h>
-#include <pakfire/repo.h>
-#include <pakfire/repocache.h>
-#include <pakfire/types.h>
-#include <pakfire/util.h>
-
-static char* pakfire_repocache_prefix(PakfireRepoCache repo_cache) {
-       const char* repo_name = pakfire_repo_get_name(repo_cache->repo);
-
-       char buffer[STRING_SIZE] = "";
-       snprintf(buffer, sizeof(buffer), "repodata/%s", repo_name);
-
-       return pakfire_strdup(buffer);
-}
-
-PAKFIRE_EXPORT PakfireRepoCache pakfire_repocache_create(PakfireRepo repo) {
-       PakfireRepoCache repo_cache = pakfire_calloc(1, sizeof(*repo_cache));
-
-       repo_cache->repo = repo;
-       repo_cache->prefix = pakfire_repocache_prefix(repo_cache);
-
-       return repo_cache;
-}
-
-PAKFIRE_EXPORT void pakfire_repocache_free(PakfireRepoCache repo_cache) {
-       pakfire_free(repo_cache->prefix);
-       pakfire_free(repo_cache);
-}
-
-PAKFIRE_EXPORT char* pakfire_repocache_get_cache_path(PakfireRepoCache repo_cache, const char* path) {
-       return pakfire_path_join(repo_cache->prefix, path);
-}
-
-PAKFIRE_EXPORT char* pakfire_repocache_get_full_path(PakfireRepoCache repo_cache, const char* path) {
-       char* cache_path = pakfire_repocache_get_cache_path(repo_cache, path);
-
-       PakfireCache cache = pakfire_repocache_cache(repo_cache);
-       char* full_path = pakfire_cache_get_full_path(cache, cache_path);
-
-       pakfire_free(cache_path);
-
-       return full_path;
-}
-
-PAKFIRE_EXPORT int pakfire_repocache_has_file(PakfireRepoCache repo_cache, const char* filename) {
-       char* cache_filename = pakfire_repocache_get_cache_path(repo_cache, filename);
-
-       PakfireCache cache = pakfire_repocache_cache(repo_cache);
-       int r = pakfire_cache_access(cache, cache_filename, R_OK);
-
-       pakfire_free(cache_filename);
-       return r;
-}
-
-PAKFIRE_EXPORT int pakfire_repocache_age(PakfireRepoCache repo_cache, const char* filename) {
-       char* cache_filename = pakfire_repocache_get_cache_path(repo_cache, filename);
-
-       PakfireCache cache = pakfire_repocache_cache(repo_cache);
-       int age = pakfire_cache_age(cache, cache_filename);
-       pakfire_free(cache_filename);
-
-       return age;
-}
-
-PAKFIRE_EXPORT FILE* pakfire_repocache_open(PakfireRepoCache repo_cache, const char* filename, const char* flags) {
-       char* cache_filename = pakfire_repocache_get_cache_path(repo_cache, filename);
-
-       PakfireCache cache = pakfire_repocache_cache(repo_cache);
-       FILE* fp = pakfire_cache_open(cache, cache_filename, flags);
-       pakfire_free(cache_filename);
-
-       return fp;
-}