[pacman-dev] [PATCH] Fix rewinddir regression
Dan McGee
dan at archlinux.org
Mon May 12 20:02:06 EDT 2008
Commit 046003844739416ff6d168dd2dec76490adb0727 caused a regression when
rereading the pkgcache after updating the on-disk databases. A rewinddir
call was errantly removed. This patch looks a bit more significant than
simply replacing the rewinddir command, but that is what it does in addition
to moving the db pkgcache population to a new _alpm_db_populate method and
removing what I'm 99% positive are extra calls setting pkg->origin data.
Signed-off-by: Dan McGee <dan at archlinux.org>
---
lib/libalpm/be_files.c | 17 +++++++++++++++++
lib/libalpm/cache.c | 13 ++-----------
lib/libalpm/db.h | 1 +
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 1e59055..7261e06 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -373,6 +373,23 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, const char *target)
return(pkg);
}
+int _alpm_db_populate(pmdb_t *db)
+{
+ pmpkg_t *info;
+ int count = 0;
+
+ rewinddir(db->handle);
+ 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);
+ /* add to the collection */
+ db->pkgcache = alpm_list_add(db->pkgcache, info);
+ count++;
+ }
+
+ return(count);
+}
+
int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
{
FILE *fp = NULL;
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index fcd555e..57784e8 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -40,8 +40,7 @@
*/
int _alpm_db_load_pkgcache(pmdb_t *db)
{
- pmpkg_t *info;
- int count = 0;
+ int count;
ALPM_LOG_FUNC;
@@ -54,15 +53,7 @@ int _alpm_db_load_pkgcache(pmdb_t *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++;
- }
+ count = _alpm_db_populate(db);
db->pkgcache = alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp);
return(0);
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index f6e0c3c..17cf317 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -63,6 +63,7 @@ alpm_list_t *_alpm_db_whatprovides(pmdb_t *db, const char *package);
int _alpm_db_open(pmdb_t *db);
void _alpm_db_close(pmdb_t *db);
pmpkg_t *_alpm_db_scan(pmdb_t *db, const char *target);
+int _alpm_db_populate(pmdb_t *db);
int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info);
--
1.5.5.1
More information about the pacman-dev
mailing list