Permalink
Browse files

Merge pull request #349 from namore/master

Fix of a (minor) issue: pkg add shows wrong version number in "package already installed" message
  • Loading branch information...
2 parents 419e47b + b4d7a5b commit a5cbd5a265edd80ffaa1e89e477bbed10ddd8e52 @dnaeon dnaeon committed Sep 6, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 libpkg/pkg_add.c
View
@@ -127,6 +127,8 @@ pkg_add(struct pkgdb *db, const char *path, unsigned flags)
struct archive_entry *ae;
struct pkg *pkg = NULL;
struct pkg_dep *dep = NULL;
+ struct pkg *pkg_inst = NULL;
+ struct pkgdb_it *it = NULL;
bool extract = true;
bool handle_rc = false;
char dpath[MAXPATHLEN + 1];
@@ -181,10 +183,15 @@ pkg_add(struct pkgdb *db, const char *path, unsigned flags)
* Check if the package is already installed
*/
- ret = pkg_is_installed(db, origin);
+ ret = EPKG_FATAL; // assume package is not installed
+ if ((it = pkgdb_query(db, origin, MATCH_EXACT)) != NULL) {
+ ret = pkgdb_it_next(it, &pkg_inst, PKG_LOAD_BASIC);
+ pkgdb_it_free(it);
+ }
if (ret == EPKG_OK) {
- pkg_emit_already_installed(pkg);
+ pkg_emit_already_installed(pkg_inst);
+ pkg_free(pkg_inst);
retcode = EPKG_INSTALLED;
goto cleanup;
} else if (ret != EPKG_END) {

0 comments on commit a5cbd5a

Please sign in to comment.