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 \
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 \
#include <pakfire/errno.h>
#include <pakfire/package.h>
#include <pakfire/repo.h>
-#include <pakfire/repocache.h>
#include <pakfire/util.h>
#include "package.h"
}
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);
#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);
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
+++ /dev/null
-/*#############################################################################
-# #
-# 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 */
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;
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;
#include <pakfire/relation.h>
#include <pakfire/relationlist.h>
#include <pakfire/repo.h>
-#include <pakfire/repocache.h>
#include <pakfire/util.h>
struct _PakfirePackage {
#include <pakfire/pool.h>
#include <pakfire/private.h>
#include <pakfire/repo.h>
-#include <pakfire/repocache.h>
#include <pakfire/types.h>
#include <pakfire/util.h>
struct _PakfireRepo {
Pakfire pakfire;
Repo* repo;
- PakfireRepoCache cache;
Repodata* filelist;
int nrefs;
};
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);
if (repo->repo)
repo->repo->appdata = NULL;
- if (repo->cache)
- pakfire_repocache_free(repo->cache);
-
pakfire_unref(repo->pakfire);
pakfire_free(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);
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;
+}
+++ /dev/null
-/*#############################################################################
-# #
-# 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;
-}