Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Properly handle lock on delete request
Baptiste Daroussin committed 11 years ago
commit b9673f0a6fb51329044754c18155abe62e09a215
parent d864686
2 files changed +14 -6
modified libpkg/pkg_jobs.c
@@ -517,7 +517,7 @@ pkg_jobs_process_add_request(struct pkg_jobs *j, bool top)
/*
 * For delete request we merely check rdeps and force flag
 */
-
static void
+
static int
pkg_jobs_process_delete_request(struct pkg_jobs *j)
{
	bool force = j->flags & PKG_FLAG_FORCE;
@@ -525,6 +525,7 @@ pkg_jobs_process_delete_request(struct pkg_jobs *j)
	struct pkg_dep *d = NULL;
	UT_array *to_process = NULL;
	struct pkg *lp;
+
	int rc = EPKG_OK;

	if (!force) {
		/*
@@ -554,13 +555,18 @@ pkg_jobs_process_delete_request(struct pkg_jobs *j)
			while ((ppkg = (struct pkg **)
							utarray_next(to_process, ppkg)) != NULL) {

-
				pkg_jobs_add_req(j, *ppkg);
+
				if (pkg_jobs_add_req(j, *ppkg) == NULL) {
+
					utarray_free(to_process);
+
					return (EPKG_FATAL);
+
				}
			}
			/* Now recursively process all items checked */
-
			pkg_jobs_process_delete_request(j);
+
			rc = pkg_jobs_process_delete_request(j);
		}
		utarray_free(to_process);
	}
+

+
	return (rc);
}

static int
@@ -1284,9 +1290,8 @@ jobs_solve_deinstall(struct pkg_jobs *j)
	}

	j->solved = 1;
-
	pkg_jobs_process_delete_request(j);

-
	return( EPKG_OK);
+
	return (pkg_jobs_process_delete_request(j));
}

static int
modified src/delete.c
@@ -183,8 +183,11 @@ exec_delete(int argc, char **argv)
	if (pkg_jobs_add(jobs, match, argv, argc) == EPKG_FATAL)
		goto cleanup;

-
	if (pkg_jobs_solve(jobs) != EPKG_OK)
+
	if (pkg_jobs_solve(jobs) != EPKG_OK) {
+
		fprintf(stderr, "Cannot perform request\n");
+
		retcode = EX_NOPERM;
		goto cleanup;
+
	}

	/* check if we have something to deinstall */
	if ((nbactions = pkg_jobs_count(jobs)) == 0) {