return obj;
}
+static PyObject* Repo_clean(RepoObject* self, PyObject* args) {
+ int r = pakfire_repo_clean(self->repo);
+
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef Repo_methods[] = {
{
"cache_age",
METH_VARARGS,
NULL
},
+ {
+ "clean",
+ (PyCFunction)Repo_clean,
+ METH_VARARGS,
+ NULL,
+ },
{
"read_solv",
(PyCFunction)Repo_read_solv,
PakfireRepoCache pakfire_repo_get_cache(PakfireRepo repo);
+int pakfire_repo_clean(PakfireRepo repo);
+
#ifdef PAKFIRE_PRIVATE
struct _PakfireRepo {
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 {
# repo
pakfire_repo_cmp;
pakfire_repo_count;
+ pakfire_repo_clean;
pakfire_repo_create;
pakfire_repo_free;
pakfire_repo_get_cache;
# repocache
pakfire_repocache_age;
pakfire_repocache_create;
+ pakfire_repocache_destroy;
pakfire_repocache_free;
pakfire_repocache_get_cache_path;
pakfire_repocache_get_full_path;
# #
#############################################################################*/
+#include <assert.h>
#include <string.h>
#include <solv/repo.h>
}
PakfireRepoCache pakfire_repo_get_cache(PakfireRepo repo) {
+ assert(repo);
+
return repo->cache;
}
+
+int pakfire_repo_clean(PakfireRepo repo) {
+ PakfireRepoCache cache = pakfire_repo_get_cache(repo);
+
+ if (cache)
+ return pakfire_repocache_destroy(cache);
+
+ return 0;
+}
# #
#############################################################################*/
+#define _XOPEN_SOURCE 500
+#include <ftw.h>
#include <stdio.h>
#include <sys/stat.h>
return fp;
}
+
+static int _unlink(const char* path, const struct stat* stat, int typeflag, struct FTW* ftwbuf) {
+ return remove(path);
+}
+
+int pakfire_repocache_destroy(PakfireRepoCache repo_cache) {
+ // Completely delete the tree of files
+ return nftw(repo_cache->prefix, _unlink, 64, FTW_DEPTH|FTW_PHYS);
+}
"""
self.opened = False
- def clean(self):
- """
- Cleanup all temporary files of this repository.
- """
- log.info("Cleaning up repository '%s'..." % self.name)
-
- # Clear all packages in the index.
- self.index.clear()
-
def dump(self, long=False, filelist=False):
dumps = []
# Dump all package information of the packages in this repository.
return priority
- def cache_path(self, *paths):
- return os.path.join(
- "repodata",
- self.distro.sname,
- self.distro.release,
- self.name,
- self.distro.arch,
- *paths
- )
-
- def clean(self):
- base.RepositoryFactory.clean(self)
-
- # Remove all files in the files cache.
- self.cache.destroy()
-
def open(self):
# First update the repository metadata.
self.update_metadata()