Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=1d4cbea36ccc8a72914c2d0ab4ae33bf19d07464

commit 1d4cbea36ccc8a72914c2d0ab4ae33bf19d07464
Author: Michel Hermier <herm...@frugalware.org>
Date:   Wed Nov 13 22:30:42 2013 +0100

libpacman: Make mtime2 a time_t in _pacman_downloadfiles_forreal.

diff --git a/lib/libpacman/db/syncdb.c b/lib/libpacman/db/syncdb.c
index 7208ffd..85a16c8 100644
--- a/lib/libpacman/db/syncdb.c
+++ b/lib/libpacman/db/syncdb.c
@@ -94,7 +94,7 @@ int _pacman_syncdb_update(pmdb_t *db, int force)
{
char path[PATH_MAX], dirpath[PATH_MAX];
pmlist_t *files = NULL;
-       char newmtime[16] = "";
+       time_t newmtime = (time_t) -1;
char lastupdate[16] = "";
int ret, updated=0;

@@ -112,7 +112,7 @@ int _pacman_syncdb_update(pmdb_t *db, int force)

snprintf(path, PATH_MAX, "%s%s", handle->root, handle->dbpath);

-       ret = _pacman_downloadfiles_forreal(db->servers, path, files, 
lastupdate, newmtime, 0);
+       ret = _pacman_downloadfiles_forreal(db->servers, path, files, 
lastupdate, &newmtime, 0);
FREELIST(files);
if(ret != 0) {
if(ret == -1) {
@@ -121,7 +121,7 @@ int _pacman_syncdb_update(pmdb_t *db, int force)
}
return 1; /* Means up2date */
} else {
-               if(!_pacman_strempty(newmtime)) {
+               if(newmtime != ((time_t) -1)) {
_pacman_log(PM_LOG_DEBUG, _("sync: new mtime for %s: %s\n"), db->treename, 
newmtime);
updated = 1;
}
@@ -135,7 +135,7 @@ int _pacman_syncdb_update(pmdb_t *db, int force)
_pacman_db_free_pkgcache(db);

if(updated) {
-                       _pacman_db_setlastupdate(db, newmtime);
+                       _pacman_db_settimestamp(db, &newmtime);
}
}
return 0;
diff --git a/lib/libpacman/server.c b/lib/libpacman/server.c
index 7d2e22c..d454f98 100644
--- a/lib/libpacman/server.c
+++ b/lib/libpacman/server.c
@@ -35,6 +35,7 @@
/* pacman-g2 */
#include "server.h"

+#include "io/ftp.h"
#include "util/list.h"
#include "util/log.h"
#include "util/stringlist.h"
@@ -154,7 +155,7 @@ int _pacman_downloadfiles(pmlist_t *servers, const char 
*localpath, pmlist_t *fi
*         -1 on error
*/
int _pacman_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
-       pmlist_t *files, const char *mtime1, char *mtime2, int skip)
+       pmlist_t *files, const char *mtime1, time_t *mtime2, int skip)
{
int fsz;
netbuf *control = NULL;
@@ -398,8 +399,10 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const 
char *localpath,
complete = _pacman_list_add(complete, fn);
} else {
if(mtime2) {
-                                                                       
strncpy(mtime2, fmtime, 15); /* YYYYMMDDHHMMSS (=14b) */
-                                                                       
mtime2[14] = '\0';
+                                                                       
if(_pacman_ftp_strpmdtm(fmtime, mtime2) == NULL) {
+                                                                               
_pacman_log(PM_LOG_WARNING, _("failed to get mtime for %s\n"), fn);
+                                                                               
*mtime2 = (time_t) -1;
+                                                                       }
}
}
}
@@ -501,7 +504,6 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const 
char *localpath,
fmtime1.tm_wday = diff+(diff >= 3 ? -3 : 4);

}
-                                       fmtime2.tm_year = 0;
if(!HttpGet(server->server, output, src, &fsz, control, (pm_dloffset ? 
*pm_dloffset:0),
(mtime1) ? &fmtime1 : NULL, (mtime2) ? &fmtime2 : NULL)) {
if(strstr(FtpLastResponse(control), "304")) {
@@ -520,12 +522,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const 
char *localpath,
}
} else {
if(mtime2) {
-                                                       if(fmtime2.tm_year) {
-                                                               /* date 
conversion from "rfc1123-date" to YYYYMMDDHHMMSS */
-                                                               sprintf(mtime2, 
"%4d%02d%02d%02d%02d%02d",
-                                                                       
fmtime2.tm_year+1900, fmtime2.tm_mon+1, fmtime2.tm_mday,
-                                                                       
fmtime2.tm_hour, fmtime2.tm_min, fmtime2.tm_sec);
-                                                       } else {
+                                                       if((*mtime2 = 
mktime(&fmtime2)) == ((time_t) -1)) {
_pacman_log(PM_LOG_WARNING, _("failed to get mtime for %s\n"), fn);
}
}
diff --git a/lib/libpacman/server.h b/lib/libpacman/server.h
index d5bd3f1..4a96508 100644
--- a/lib/libpacman/server.h
+++ b/lib/libpacman/server.h
@@ -47,7 +47,7 @@ pmserver_t *_pacman_server_new(char *url);
void _pacman_server_free(void *data);
int _pacman_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t 
*files, int skip);
int _pacman_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
-       pmlist_t *files, const char *mtime1, char *mtime2, int skip);
+       pmlist_t *files, const char *mtime1, time_t *mtime2, int skip);

char *_pacman_fetch_pkgurl(char *target);
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to