Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-11-16 11:51:26 -0600
committerDan McGee <dan@archlinux.org>2007-11-16 11:51:26 -0600
commit3cd684b41dd606d42da76fcc3911be446dd3b78b (patch)
treef44f44424df6009153376b314e77facbd0f3f173 /lib/libalpm/db.c
parent6f2b43624915e3e1928cad2bbe14fd8b1ab21e12 (diff)
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 <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c20
1 files changed, 11 insertions, 9 deletions
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 <stdlib.h>
#include <errno.h>
#include <string.h>
+#include <stdint.h> /* uintmax_t */
#include <sys/stat.h>
#include <dirent.h>
#include <regex.h>
+#include <time.h>
/* 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);