From 562442633a9dd8026d914d785f15de2d0a95fdef Mon Sep 17 00:00:00 2001 From: Nagy Gabor Date: Fri, 28 Mar 2008 17:08:48 +0100 Subject: Use pkgcache instead of db_scan in remove.c This should be a notable speed-up (apart from kernel cache). Signed-off-by: Nagy Gabor Signed-off-by: Dan McGee --- lib/libalpm/remove.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 56d02b9c..a0f9963a 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -61,7 +61,7 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1); } - if((info = _alpm_db_scan(db, name)) == NULL) { + if((info = _alpm_db_get_pkgfromcache(db, name)) == NULL) { _alpm_log(PM_LOG_DEBUG, "could not find %s in database\n", name); RET_ERR(PM_ERR_PKG_NOT_FOUND, -1); } @@ -77,7 +77,7 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) } _alpm_log(PM_LOG_DEBUG, "adding %s in the targets list\n", info->name); - trans->packages = alpm_list_add(trans->packages, info); + trans->packages = alpm_list_add(trans->packages, _alpm_pkg_dup(info)); return(0); } @@ -107,12 +107,12 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) alpm_list_t *i; for(i = lp; i; i = i->next) { pmdepmissing_t *miss = (pmdepmissing_t *)i->data; - pmpkg_t *info = _alpm_db_scan(db, miss->target); + pmpkg_t *info = _alpm_db_get_pkgfromcache(db, miss->target); if(info) { if(!_alpm_pkg_find(alpm_pkg_get_name(info), trans->packages)) { _alpm_log(PM_LOG_DEBUG, "pulling %s in the targets list\n", alpm_pkg_get_name(info)); - trans->packages = alpm_list_add(trans->packages, info); + trans->packages = alpm_list_add(trans->packages, _alpm_pkg_dup(info)); } } else { _alpm_log(PM_LOG_ERROR, _("could not find %s in database -- skipping\n"), -- cgit v1.2.3-24-g4f1b From 3fe43ffa04efd9937205938ef74d9dbba1a7aa42 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Fri, 28 Mar 2008 23:58:33 +0100 Subject: Duplicate the result of archive_entry_pathname. After the libarchive upgrade from 2.4.12 to 2.4.14, our usage of archive_entry_pathname became dangerous. We were using the result of that function even after calls to archive_entry_set_pathname. With 2.4.14, the entryname becomes wrong after these calls, and so all the future use of entryname are bogus. entryname is used quite a lot for logging, so that's not so bad. But it's also used for the backup handling, so that's not very cool. For example, reinstalling a package with backup entries will erase all the md5 entries from the DB, because they won't be found back. entryname is now a static string so that we can easily keep the result of archive_entry_pathname. Signed-off-by: Chantry Xavier [Dan: fixed version numbers in commit message] Signed-off-by: Dan McGee --- lib/libalpm/add.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 8b06bef5..42015224 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -290,7 +290,7 @@ static int extract_single_file(struct archive *archive, struct archive_entry *entry, pmpkg_t *newpkg, pmpkg_t *oldpkg, pmtrans_t *trans, pmdb_t *db) { - const char *entryname; /* the name of the file in the archive */ + char entryname[PATH_MAX]; /* the name of the file in the archive */ mode_t entrymode; char filename[PATH_MAX]; /* the actual file we're extracting */ int needbackup = 0, notouch = 0; @@ -300,7 +300,7 @@ static int extract_single_file(struct archive *archive, ARCHIVE_EXTRACT_TIME; int errors = 0; - entryname = archive_entry_pathname(entry); + strncpy(entryname, archive_entry_pathname(entry), PATH_MAX); entrymode = archive_entry_mode(entry); memset(filename, 0, PATH_MAX); /* just to be sure */ -- cgit v1.2.3-24-g4f1b