Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix conflicts registration.
Vsevolod Stakhov committed 10 years ago
commit beaf8721776c42c7bfcb9cd0d6457dfacfc23a37
parent 17674a5
1 file changed +41 -19
modified libpkg/pkg_jobs_conflicts.c
@@ -176,14 +176,18 @@ pkg_conflicts_register(struct pkg *p1, struct pkg *p2, enum pkg_conflict_type ty
		if (test == NULL) {
			c1->uid = strdup(p2->uid);
			HASH_ADD_KEYPTR(hh, p1->conflicts, c1->uid, strlen(c1->uid), c1);
-
			pkg_debug(2, "registering conflict between %s and %s", p1->uid, p2->uid);
+
			pkg_debug(2, "registering conflict between %s(%s) and %s(%s)",
+
					p1->uid, p1->type == PKG_INSTALLED ? "l" : "r",
+
					p2->uid, p2->type == PKG_INSTALLED ? "l" : "r");
		}

		HASH_FIND_STR(p2->conflicts, p1->uid, test);
		if (test == NULL) {
			c1->uid = strdup(p1->uid);
			HASH_ADD_KEYPTR(hh, p2->conflicts, c2->uid, strlen(c2->uid), c2);
-
			pkg_debug(2, "registering conflict between %s and %s", p2->uid, p1->uid);
+
			pkg_debug(2, "registering conflict between %s(%s) and %s(%s)",
+
					p2->uid, p2->type == PKG_INSTALLED ? "l" : "r",
+
					p1->uid, p1->type == PKG_INSTALLED ? "l" : "r");
		}
	}
}
@@ -205,7 +209,7 @@ pkg_conflicts_need_conflict(struct pkg_jobs *j, struct pkg *p1, struct pkg *p2)
{
	struct pkg_file *fcur, *ftmp, *ff;
	struct pkg_dir *df;
-
	struct pkg_conflict *c;
+
	struct pkg_conflict *c1, *c2;

	if (pkgdb_ensure_loaded(j->db, p1, PKG_LOAD_FILES|PKG_LOAD_DIRS) != EPKG_OK ||
			pkgdb_ensure_loaded(j->db, p2, PKG_LOAD_FILES|PKG_LOAD_DIRS)
@@ -223,8 +227,9 @@ pkg_conflicts_need_conflict(struct pkg_jobs *j, struct pkg *p1, struct pkg *p2)
	/*
	 * Check if we already have this conflict registered
	 */
-
	HASH_FIND_STR(p1->conflicts, p2->uid, c);
-
	if (c != NULL)
+
	HASH_FIND_STR(p1->conflicts, p2->uid, c1);
+
	HASH_FIND_STR(p2->conflicts, p1->uid, c2);
+
	if (c1 != NULL && c2 != NULL)
		return false;

	/*
@@ -255,22 +260,39 @@ pkg_conflicts_register_unsafe(struct pkg *p1, struct pkg *p2,
{
	struct pkg_conflict *c1, *c2;

-
	pkg_conflict_new(&c1);
-
	pkg_conflict_new(&c2);
-
	c1->type = c2->type = type;
-
	c1->uid = strdup(p2->uid);
-
	c2->uid = strdup(p2->uid);
-

-
	if (use_digest) {
-
		/* We also add digest information into account */
-
		c1->digest = strdup(p2->digest);
-
		c2->digest = strdup(p1->digest);
+
	HASH_FIND_STR(p1->conflicts, p2->uid, c1);
+
	HASH_FIND_STR(p2->conflicts, p1->uid, c2);
+

+
	if (c1 == NULL) {
+
		pkg_conflict_new(&c1);
+
		c1->type = type;
+
		c1->uid = strdup(p2->uid);
+

+
		if (use_digest) {
+
			c1->digest = strdup(p2->digest);
+
		}
+

+
		HASH_ADD_KEYPTR(hh, p1->conflicts, c1->uid, strlen(c1->uid), c1);
+
	}
+

+
	if (c2 == NULL) {
+
		pkg_conflict_new(&c2);
+
		c2->type = type;
+

+
		c2->uid = strdup(p1->uid);
+

+
		if (use_digest) {
+
			/* We also add digest information into account */
+

+
			c2->digest = strdup(p1->digest);
+
		}
+

+
		HASH_ADD_KEYPTR(hh, p2->conflicts, c2->uid, strlen(c2->uid), c2);
	}

-
	HASH_ADD_KEYPTR(hh, p1->conflicts, c1->uid, strlen(c1->uid), c1);
-
	HASH_ADD_KEYPTR(hh, p2->conflicts, c2->uid, strlen(c1->uid), c2);
-
	pkg_debug(2, "registering conflict between %s and %s on path %s",
-
		p1->uid, p2->uid, path);
+
	pkg_debug(2, "registering conflict between %s(%s) and %s(%s) on path %s",
+
			p1->uid, p1->type == PKG_INSTALLED ? "l" : "r",
+
			p2->uid, p2->type == PKG_INSTALLED ? "l" : "r", path);
}

/*