summaryrefslogtreecommitdiff
path: root/lib/libalpm/be_sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-07 20:42:15 -0500
committerDan McGee <dan@archlinux.org>2011-06-24 03:46:12 -0500
commit79e98316ea89486d107466858543e965bcfbb0a9 (patch)
treee22572124cffc7275a200e4964c4ea112457fa52 /lib/libalpm/be_sync.c
parent1150d9e15aaea2ae1f259995d11442f491ef0af7 (diff)
downloadpacman-79e98316ea89486d107466858543e965bcfbb0a9.tar.xz
Add a 'valid' flag to the database object
Start by converting all of our flags to a 'status' bitmask (pkgcache status, grpcache status). Add a new 'valid' flag as well. This will let us keep track if the database itself has been marked valid in whatever fashion. For local databases at the moment we ensure there are no depends files; for sync databases we ensure the PGP signature is valid if required/requested. The loading of the pkgcache is prohibited if the database is invalid. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_sync.c')
-rw-r--r--lib/libalpm/be_sync.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 1a434f24..c1703ffe 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -69,9 +69,15 @@ static char *get_sync_dir(pmhandle_t *handle)
static int sync_db_validate(pmdb_t *db)
{
+ pgp_verify_t check_sig;
+
+ if(db->status & DB_STATUS_VALID) {
+ return 0;
+ }
+
/* this takes into account the default verification level if UNKNOWN
* was assigned to this db */
- pgp_verify_t check_sig = _alpm_db_get_sigverify_level(db);
+ check_sig = _alpm_db_get_sigverify_level(db);
if(check_sig != PM_PGP_VERIFY_NEVER) {
int ret;
@@ -83,6 +89,7 @@ static int sync_db_validate(pmdb_t *db)
/* we can skip any validation if the database doesn't exist */
if(access(dbpath, R_OK) != 0 && errno == ENOENT) {
+ goto valid;
return 0;
}
@@ -95,6 +102,8 @@ static int sync_db_validate(pmdb_t *db)
}
}
+valid:
+ db->status |= DB_STATUS_VALID;
return 0;
}
@@ -215,6 +224,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
/* Cache needs to be rebuilt */
_alpm_db_free_pkgcache(db);
+ db->status &= ~DB_STATUS_VALID;
if(sync_db_validate(db)) {
/* pm_errno should be set */
ret = -1;