From 3cd684b41dd606d42da76fcc3911be446dd3b78b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 16 Nov 2007 11:51:26 -0600 Subject: libalpm: simplify sync db lastupdate Legacy code is hitting the trash here. Remove unnecessary _alpm_time2string time storage abstraction in favor of just writing the time_t value to the disk. The only drawback is that everyone's sync DBs will have to be updated at least once so that the lastupdate values are stored right. :) Signed-off-by: Dan McGee --- lib/libalpm/db.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/libalpm/db.c') diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 150b365a..8e4f3fa4 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -30,9 +30,11 @@ #include #include #include +#include /* uintmax_t */ #include #include #include +#include /* libalpm */ #include "db.h" @@ -221,8 +223,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) alpm_list_t *lp; char path[PATH_MAX]; alpm_list_t *files = NULL; - char newmtime[16] = ""; - char lastupdate[16] = ""; + time_t newmtime = 0, lastupdate = 0; const char *dbpath; int ret; @@ -245,9 +246,10 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) if(!force) { /* get the lastupdate time */ - _alpm_db_getlastupdate(db, lastupdate); - if(strlen(lastupdate) == 0) { - _alpm_log(PM_LOG_DEBUG, "failed to get lastupdate time for %s (no big deal)\n", db->treename); + lastupdate = _alpm_db_getlastupdate(db); + if(lastupdate == 0) { + _alpm_log(PM_LOG_DEBUG, "failed to get lastupdate time for %s\n", + db->treename); } } @@ -258,7 +260,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) dbpath = alpm_option_get_dbpath(); ret = _alpm_downloadfiles_forreal(db->servers, dbpath, files, lastupdate, - newmtime, NULL, 0); + &newmtime, NULL, 0); FREELIST(files); if(ret == 1) { /* mtimes match, do nothing */ @@ -271,9 +273,9 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) downloadLastErrString, downloadLastErrCode); RET_ERR(PM_ERR_DB_SYNC, -1); } else { - if(strlen(newmtime)) { - _alpm_log(PM_LOG_DEBUG, "sync: new mtime for %s: %s\n", - db->treename, newmtime); + if(newmtime != 0) { + _alpm_log(PM_LOG_DEBUG, "sync: new mtime for %s: %ju\n", + db->treename, (uintmax_t)newmtime); _alpm_db_setlastupdate(db, newmtime); } snprintf(path, PATH_MAX, "%s%s" DBEXT, dbpath, db->treename); -- cgit v1.2.3-24-g4f1b