Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/be_sync.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index b09b0608..200e3817 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -177,6 +177,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
char *syncpath;
const char *dbext;
alpm_list_t *i;
+ int updated = 0;
int ret = -1;
mode_t oldmask;
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);
_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 */
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
if(!sigpath) {
@@ -296,32 +298,31 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
}
}
- if(ret == 1) {
- /* 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;
- }
+ if(updated) {
+ /* Cache needs to be rebuilt */
+ _alpm_db_free_pkgcache(db);
- /* Cache needs to be rebuilt */
- _alpm_db_free_pkgcache(db);
+ /* clear all status flags regarding validity/existence */
+ db->status &= ~DB_STATUS_VALID;
+ db->status &= ~DB_STATUS_INVALID;
+ db->status &= ~DB_STATUS_EXISTS;
+ db->status &= ~DB_STATUS_MISSING;
- /* clear all status flags regarding validity/existence */
- db->status &= ~DB_STATUS_VALID;
- db->status &= ~DB_STATUS_INVALID;
- db->status &= ~DB_STATUS_EXISTS;
- db->status &= ~DB_STATUS_MISSING;
+ /* if the download failed skip validation to preserve the download error */
+ if(ret != -1 && sync_db_validate(db) != 0) {
+ /* pm_errno should be set */
+ ret = -1;
+ }
+ }
- if(sync_db_validate(db)) {
- /* pm_errno should be set */
- 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);
free(syncpath);
umask(oldmask);