Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a progress when fetching (#660)
Baptiste Daroussin committed 9 years ago
commit 95aabc249974e94e5a3bf9009f77fe30fbce7ddd
parent c886987
3 files changed +11 -3
modified src/event.c
@@ -217,8 +217,10 @@ job_status_begin(UT_string *msg)
		utstring_printf(msg, "`-- ");
	}

-
	if (nbactions > 0 && nbdone > 0)
+
	if ((nbtodl > 0 || nbactions > 0) && nbdone > 0)
		utstring_printf(msg, "[%d/%d] ", nbdone, nbactions);
+
	if (nbtodl > 0 && nbtodl == nbdone)
+
		nbdone = 0;
}

static int
@@ -626,6 +628,7 @@ event_callback(void *data, struct pkg_event *ev)
			printf("\n");
		break;
	case PKG_EVENT_FETCH_BEGIN:
+
		nbdone++;
		if (quiet)
			break;
		filename = strrchr(ev->e_fetching.url, '/');
modified src/pkgcli.h
@@ -38,8 +38,10 @@ extern bool quiet;
extern int nbactions;
int nbactions;
extern int nbdone;
-
extern bool newpkgversion;
int nbdone;
+
extern bool newpkgversion;
+
extern int nbtodl;
+
int nbtodl;

/* pkg add */
int exec_add(int, char **);
modified src/utils.c
@@ -739,12 +739,14 @@ set_jobs_summary_pkg(struct pkg_jobs *jobs, struct pkg *new_pkg,
		} else
			break;

-
		if ((ret == EPKG_OK || ret == EPKG_FATAL) && (stat(path, &st) == -1 || pkgsize != st.st_size))
+
		if ((ret == EPKG_OK || ret == EPKG_FATAL) && (stat(path, &st) == -1 || pkgsize != st.st_size)) {
			/* file looks corrupted (wrong size),
					   assume a checksum mismatch will
					   occur later and the file will be
					   fetched from remote again */
			*dlsize += pkgsize;
+
			nbtodl += 1;
+
		}

		if (old_pkg != NULL) {
			switch (pkg_version_change_between(new_pkg, old_pkg)) {
@@ -918,6 +920,7 @@ print_jobs_summary(struct pkg_jobs *jobs, const char *msg, ...)
	memset(disp, 0, sizeof(disp));
	memset(&sum, 0, sizeof(sum));

+
	nbtodl = 0;
	while (pkg_jobs_iter(jobs, &iter, &new_pkg, &old_pkg, &type)) {
		set_jobs_summary_pkg(jobs, new_pkg, old_pkg, type, &oldsize,
		&newsize, &dlsize, disp, &sum);