From fcdb316ab7320babb83dd901f511d65770166d32 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Mon, 1 Mar 2010 11:20:17 +0200 Subject: [PATCH] db: read also non-repository package index if reading repository indexes otherwise regeneration of non-repository index might go wrong or we might delete too many files from cache when doing 'cache clean'. --- src/database.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/database.c b/src/database.c index 2fcb275..9c2e009 100644 --- a/src/database.c +++ b/src/database.c @@ -897,14 +897,6 @@ static int apk_db_read_state(struct apk_database *db, int flags) bs->close(bs, NULL); } - if (apk_db_cache_active(db)) { - bs = apk_bstream_from_file(db->cache_fd, "installed"); - if (bs != NULL) { - apk_db_index_read(db, bs, -2); - bs->close(bs, NULL); - } - } - bs = apk_bstream_from_file(db->root_fd, "var/lib/apk/triggers"); if (bs != NULL) { apk_db_triggers_read(db, bs); @@ -1139,6 +1131,14 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) } if (!(dbopts->open_flags & APK_OPENF_NO_REPOS)) { + if (apk_db_cache_active(db)) { + bs = apk_bstream_from_file(db->cache_fd, "installed"); + if (bs != NULL) { + apk_db_index_read(db, bs, -2); + bs->close(bs, NULL); + } + } + list_for_each_entry(repo, &dbopts->repository_list, list) { r = apk_db_add_repository(db, APK_BLOB_STR(repo->url)); rr = r ?: rr;