Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2013-07-16 21:51:16 +1000
committerAllan McRae <allan@archlinux.org>2014-09-23 21:43:05 +1000
commitd02efd2f204cfdd99d6e161b1ce9d4478b08b8e2 (patch)
treeda7c24edecabcea50f3ed6e3fef3b9ce9ca82552 /lib
parent1660ed3cf9069f84d96670b5443a9f1542b7865d (diff)
Check the version of the local database during validation
When we check the database version directly, there is no longer a need to scan for depends files. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/be_local.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 857c984f..1b333e44 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -398,9 +398,11 @@ static int local_db_validate(alpm_db_t *db)
{
struct dirent *ent = NULL;
const char *dbpath;
+ DIR *dbdir;
char dbverpath[PATH_MAX];
FILE *dbverfile;
- DIR *dbdir;
+ int t;
+ size_t version;
if(db->status & DB_STATUS_VALID) {
return 0;
@@ -437,7 +439,7 @@ static int local_db_validate(alpm_db_t *db)
db->status |= DB_STATUS_EXISTS;
db->status &= ~DB_STATUS_MISSING;
- snprintf(dbverpath, PATH_MAX, "%s.alpm_db_version", dbpath);
+ snprintf(dbverpath, PATH_MAX, "%sALPM_DB_VERSION", dbpath);
if((dbverfile = fopen(dbverpath, "r")) == NULL) {
/* create dbverfile if local database is empty - otherwise version error */
@@ -453,26 +455,17 @@ static int local_db_validate(alpm_db_t *db)
local_db_add_version(db, dbpath);
goto version_latest;
}
- fclose(dbverfile);
- while((ent = readdir(dbdir)) != NULL) {
- const char *name = ent->d_name;
- char path[PATH_MAX];
+ t = fscanf(dbverfile, "%zu", &version);
+ fclose(dbverfile);
- if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
- continue;
- }
- if(!is_dir(dbpath, ent)) {
- continue;
- }
+ if(t != 1) {
+ goto version_error;
+ }
- snprintf(path, PATH_MAX, "%s%s/depends", dbpath, name);
- if(access(path, F_OK) == 0) {
- /* we found a depends file- bail */
- goto version_error;
- }
+ if(version != ALPM_LOCAL_DB_VERSION) {
+ goto version_error;
}
- /* we found no depends file after full scan */
version_latest:
closedir(dbdir);