Skip to content

Commit

Permalink
Improve parsable download messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Perkin committed Feb 12, 2016
1 parent 8b1313d commit cca14b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
23 changes: 12 additions & 11 deletions download.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ sum_start(struct archive *a, void *data)
Sumfile *sum = data;
char *p;

if (!parsable) { /* human readable output */
if ((p = strrchr(sum->url->doc, '/')) != NULL)
p++;
else
p = (char *)sum->url->doc; /* should not happen */
if ((p = strrchr(sum->url->doc, '/')) != NULL)
p++;
else
p = (char *)sum->url->doc; /* should not happen */

if (parsable)
printf(MSG_DOWNLOAD_START, p);
else {
printf(MSG_DOWNLOADING, p);
fflush(stdout);
start_progress_meter(p, sum->size, &sum->pos);
} else
printf(MSG_DOWNLOAD_START);
}

return ARCHIVE_OK;
}
Expand Down Expand Up @@ -147,10 +148,10 @@ sum_close(struct archive *a, void *data)
{
Sumfile *sum = data;

if (!parsable)
stop_progress_meter();
else
if (parsable)
printf(MSG_DOWNLOAD_END);
else
stop_progress_meter();

fetchIO_close(sum->fd);
fetchFreeURL(sum->url);
Expand Down Expand Up @@ -190,7 +191,7 @@ download_pkg(char *pkg_url, FILE *fp)
pkg = (char *)pkg_url; /* should not happen */

if (parsable) {
printf(MSG_DOWNLOAD_START);
printf(MSG_DOWNLOAD_START, pkg);
} else {
printf(MSG_DOWNLOADING, pkg);
fflush(stdout);
Expand Down
4 changes: 2 additions & 2 deletions messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
/* download.c */
#define MSG_DOWNLOADING "downloading %s: 0%%"
#define MSG_DOWNLOADING_PCT "\rdownloading %s: %8s %3d%%"
#define MSG_DOWNLOAD_START "download started.\n"
#define MSG_DOWNLOAD_END "download ended.\n"
#define MSG_DOWNLOAD_START "downloading %s"
#define MSG_DOWNLOAD_END " done.\n"

/* autoremove.c */
#define MSG_AUTOREMOVE_WARNING "\
Expand Down

0 comments on commit cca14b7

Please sign in to comment.