From 6e76fd8af3113a28280077ba3da016c01a760ba2 Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Wed, 15 Feb 2006 22:51:28 +0000 Subject: - merged db_open and db_create into one single function - moved the .lastupdate support to the frontend --- lib/libalpm/alpm.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'lib/libalpm/alpm.c') diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 788e504c..5a071c32 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -187,17 +187,9 @@ pmdb_t *alpm_db_register(char *treename) RET_ERR(PM_ERR_DB_NOT_NULL, NULL); } - db = db_open(handle->root, handle->dbpath, treename); + db = db_open(handle->root, handle->dbpath, treename, DB_O_CREATE); if(db == NULL) { - /* couldn't open the db directory - try creating it */ - if(db_create(handle->root, handle->dbpath, treename) == -1) { - RET_ERR(PM_ERR_DB_CREATE, NULL); - } - db = db_open(handle->root, handle->dbpath, treename); - if(db == NULL) { - /* couldn't open the db directory */ - RET_ERR(PM_ERR_DB_OPEN, NULL); - } + RET_ERR(PM_ERR_DB_OPEN, NULL); } if(strcmp(treename, "local") == 0) { @@ -270,7 +262,6 @@ void *alpm_db_getinfo(PM_DB *db, unsigned char parm) switch(parm) { case PM_DB_TREENAME: data = db->treename; break; - case PM_DB_LASTUPDATE: data = db->lastupdate; break; default: data = NULL; } @@ -284,7 +275,7 @@ void *alpm_db_getinfo(PM_DB *db, unsigned char parm) * @param ts timestamp of the last modification time of the tarball * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int alpm_db_update(PM_DB *db, char *archive, char *ts) +int alpm_db_update(PM_DB *db, char *archive) { PMList *lp; @@ -298,12 +289,6 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts) RET_ERR(PM_ERR_DB_NOT_FOUND, -1); } - if(ts && strlen(ts) != 0) { - if(strcmp(ts, db->lastupdate) == 0) { - RET_ERR(PM_ERR_DB_UPTODATE, -1); - } - } - /* remove the old dir */ _alpm_log(PM_LOG_FLOW2, "flushing database %s/%s", handle->dbpath, db->treename); for(lp = db_get_pkgcache(db); lp; lp = lp->next) { @@ -328,12 +313,6 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts) RET_ERR(PM_ERR_SYSTEM, -1); } - if(ts && strlen(ts) != 0) { - if(db_setlastupdate(db, ts) == -1) { - RET_ERR(PM_ERR_SYSTEM, -1); - } - } - return(0); } -- cgit v1.2.3-24-g4f1b