Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add progressbar for solver.
Vsevolod Stakhov committed 11 years ago
commit a20caba819a19edb726a425a4d7bc7a9fd681aaa
parent 49e6be8
2 files changed +13 -6
modified libpkg/pkg_jobs.c
@@ -1892,7 +1892,7 @@ pkg_jobs_check_remote_candidate(struct pkg_jobs *j, struct pkg *pkg)
}

static struct pkg_jobs_install_candidate *
-
pkg_jobs_find_install_candidates(struct pkg_jobs *j)
+
pkg_jobs_find_install_candidates(struct pkg_jobs *j, size_t *count)
{
	struct pkg *pkg = NULL;
	struct pkgdb_it *it;
@@ -1905,6 +1905,7 @@ pkg_jobs_find_install_candidates(struct pkg_jobs *j)
		if (pkg_jobs_check_remote_candidate(j, pkg)) {
			c = pkg_jobs_new_candidate(pkg);
			LL_PREPEND(candidates, c);
+
			(*count)++;
		}
	}
	pkg_free(pkg);
@@ -1921,6 +1922,7 @@ jobs_solve_install_upgrade(struct pkg_jobs *j)
	char *uid;
	char sqlbuf[256];
	bool automatic, got_local;
+
	size_t jcount = 0;
	struct job_pattern *jp, *jtmp;
	struct pkg_job_request *req, *rtmp;
	unsigned flags = PKG_LOAD_BASIC|PKG_LOAD_OPTIONS|PKG_LOAD_DEPS|
@@ -1940,9 +1942,14 @@ jobs_solve_install_upgrade(struct pkg_jobs *j)

	if (j->solved == 0) {
		if (j->patterns == NULL) {
-
			candidates = pkg_jobs_find_install_candidates(j);
+
			size_t elt_num = 0;
+

+
			candidates = pkg_jobs_find_install_candidates(j, &jcount);
+

+
			pkg_emit_progress_start("Processing packages");

			LL_FOREACH(candidates, c) {
+
				pkg_emit_progress_tick(++elt_num, jcount);
				sqlite3_snprintf(sizeof(sqlbuf), sqlbuf, " WHERE id=%" PRId64,
						c->id);
				if ((it = pkgdb_query(j->db, sqlbuf, MATCH_CONDITION)) == NULL)
modified src/event.c
@@ -264,10 +264,10 @@ event_sandboxed_get_string(pkg_sandbox_cb func, char **result, int64_t *len,
static void
progress_alarm_handler(int signo)
{
-
	last_progress_slots = -1;
-

-
	if (progress_alarm)
+
	if (max_slots != last_progress_slots && progress_alarm) {
+
		last_progress_slots = -1;
		alarm(1);
+
	}
}

static void
@@ -291,7 +291,7 @@ draw_progressbar(int64_t current, int64_t total)
		}
		printf("] %" PRId64 " / %" PRId64, current, total);
	}
-
	if (current == total) {
+
	if (current >= total) {
		putchar('\n');
		last_progress_slots = -1;
		progress_alarm = false;