mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-15 13:55:09 -05:00
db_update: always clear db flags after update
Signature downloading and DB validation was being based on the most recent download status for the DB. If a DB successfully downloaded but a signature did not, db_update would move to the next server. If the next server tried does not have a more recent copy of the DB, db_update would not download the DB again and would forget that the DB had previously been updated. In this case it would skip validation entirely, leaving an updated DB with the original validation status. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
d069d9714a
commit
8ee084dbb3
@ -177,6 +177,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
|
|||||||
char *syncpath;
|
char *syncpath;
|
||||||
const char *dbext;
|
const char *dbext;
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
|
int updated = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
mode_t oldmask;
|
mode_t oldmask;
|
||||||
alpm_handle_t *handle;
|
alpm_handle_t *handle;
|
||||||
@ -239,8 +240,9 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
|
|||||||
|
|
||||||
ret = _alpm_download(&payload, syncpath, NULL, &final_db_url);
|
ret = _alpm_download(&payload, syncpath, NULL, &final_db_url);
|
||||||
_alpm_dload_payload_reset(&payload);
|
_alpm_dload_payload_reset(&payload);
|
||||||
|
updated = (updated || ret == 0);
|
||||||
|
|
||||||
if(ret == 0 && (level & ALPM_SIG_DATABASE)) {
|
if(ret != -1 && updated && (level & ALPM_SIG_DATABASE)) {
|
||||||
/* an existing sig file is no good at this point */
|
/* an existing sig file is no good at this point */
|
||||||
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
|
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
|
||||||
if(!sigpath) {
|
if(!sigpath) {
|
||||||
@ -296,17 +298,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret == 1) {
|
if(updated) {
|
||||||
/* files match, do nothing */
|
|
||||||
handle->pm_errno = 0;
|
|
||||||
goto cleanup;
|
|
||||||
} else if(ret == -1) {
|
|
||||||
/* pm_errno was set by the download code */
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
|
|
||||||
alpm_strerror(handle->pm_errno));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cache needs to be rebuilt */
|
/* Cache needs to be rebuilt */
|
||||||
_alpm_db_free_pkgcache(db);
|
_alpm_db_free_pkgcache(db);
|
||||||
|
|
||||||
@ -316,12 +308,21 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
|
|||||||
db->status &= ~DB_STATUS_EXISTS;
|
db->status &= ~DB_STATUS_EXISTS;
|
||||||
db->status &= ~DB_STATUS_MISSING;
|
db->status &= ~DB_STATUS_MISSING;
|
||||||
|
|
||||||
if(sync_db_validate(db)) {
|
/* if the download failed skip validation to preserve the download error */
|
||||||
|
if(ret != -1 && sync_db_validate(db) != 0) {
|
||||||
/* pm_errno should be set */
|
/* pm_errno should be set */
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret == -1) {
|
||||||
|
/* pm_errno was set by the download code */
|
||||||
|
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
|
||||||
|
alpm_strerror(handle->pm_errno));
|
||||||
|
} else {
|
||||||
|
handle->pm_errno = 0;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
_alpm_handle_unlock(handle);
|
_alpm_handle_unlock(handle);
|
||||||
free(syncpath);
|
free(syncpath);
|
||||||
umask(oldmask);
|
umask(oldmask);
|
||||||
|
Loading…
Reference in New Issue
Block a user