From f671147282e0f5c6a2e05c8cb7a0d5b72ef8cb61 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Mon, 12 May 2008 18:56:14 -0500 Subject: Fix rewinddir regression by cleaning up db_scan Commit 046003844739416ff6d168dd2dec76490adb0727 caused a regression when rereading the pkgcache after updating the on-disk databases. A rewinddir call was errantly removed. Instead of replacing the call to rewindir, clean up this whole mess. db_scan is used only once and with target == NULL so there was actually half the code of db_scan which was unused. This is gone now and replaced by a single new db_populate function. Dan: add_sorted ended up being 3x slower than one msort at the end, so I changed back to that. I also made one pointer variable const and merged this whole patch with my original fix for the rewinddir issue. Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- lib/libalpm/cache.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'lib/libalpm/cache.c') diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c index d65b63b3..b140476c 100644 --- a/lib/libalpm/cache.c +++ b/lib/libalpm/cache.c @@ -40,31 +40,21 @@ */ int _alpm_db_load_pkgcache(pmdb_t *db) { - pmpkg_t *info; - int count = 0; - ALPM_LOG_FUNC; if(db == NULL) { return(-1); } - _alpm_db_free_pkgcache(db); _alpm_log(PM_LOG_DEBUG, "loading package cache for repository '%s'\n", - db->treename); - - while((info = _alpm_db_scan(db, NULL)) != NULL) { - _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", - alpm_pkg_get_name(info), db->treename); - info->origin = PKG_FROM_CACHE; - info->origin_data.db = db; - /* add to the collection */ - db->pkgcache = alpm_list_add(db->pkgcache, info); - count++; + db->treename); + if(_alpm_db_populate(db) == -1) { + _alpm_log(PM_LOG_DEBUG, + "failed to load package cache for repository '%s'\n", db->treename); + return(-1); } - db->pkgcache = alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp); return(0); } -- cgit v1.2.3-54-g00ecf