Update database mtime after it has been extracted
This will reduce the need for running an -Syy if the DB was only half-extracted, as the mtime won't get updated until the new database is completely in place. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
3d10d460df
commit
f7f43dbb48
1 changed files with 12 additions and 8 deletions
|
@ -247,24 +247,22 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
||||||
snprintf(path, PATH_MAX, "%s" DBEXT, db->treename);
|
snprintf(path, PATH_MAX, "%s" DBEXT, db->treename);
|
||||||
dbpath = alpm_option_get_dbpath();
|
dbpath = alpm_option_get_dbpath();
|
||||||
|
|
||||||
ret = _alpm_download_single_file(path, db->servers, dbpath, lastupdate, &newmtime);
|
ret = _alpm_download_single_file(path, db->servers, dbpath,
|
||||||
|
lastupdate, &newmtime);
|
||||||
|
|
||||||
if(ret == 1) {
|
if(ret == 1) {
|
||||||
/* mtimes match, do nothing */
|
/* mtimes match, do nothing */
|
||||||
pm_errno = 0;
|
pm_errno = 0;
|
||||||
return(1);
|
return(1);
|
||||||
} else if(ret == -1) {
|
} else if(ret == -1) {
|
||||||
/* we use downloadLastErrString and downloadLastErrCode here, error returns from
|
/* we use downloadLastErrString and downloadLastErrCode here,
|
||||||
* libdownload */
|
* error returns from libdownload */
|
||||||
|
/* TODO we may not have used libdownload, this should change */
|
||||||
_alpm_log(PM_LOG_DEBUG, "failed to sync db: %s [%d]\n",
|
_alpm_log(PM_LOG_DEBUG, "failed to sync db: %s [%d]\n",
|
||||||
downloadLastErrString, downloadLastErrCode);
|
downloadLastErrString, downloadLastErrCode);
|
||||||
RET_ERR(PM_ERR_DB_SYNC, -1);
|
RET_ERR(PM_ERR_DB_SYNC, -1);
|
||||||
} else {
|
} else {
|
||||||
if(newmtime != 0) {
|
/* form the path to the db location */
|
||||||
_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);
|
snprintf(path, PATH_MAX, "%s%s" DBEXT, dbpath, db->treename);
|
||||||
|
|
||||||
/* remove the old dir */
|
/* remove the old dir */
|
||||||
|
@ -285,6 +283,12 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
|
||||||
if(_alpm_db_install(db, path) == -1) {
|
if(_alpm_db_install(db, path) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
/* if we have a new mtime, set the DB last update value */
|
||||||
|
if(newmtime) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "sync: new mtime for %s: %ju\n",
|
||||||
|
db->treename, (uintmax_t)newmtime);
|
||||||
|
_alpm_db_setlastupdate(db, newmtime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue