mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-15 22:05:02 -05:00
Always display download size if it applies
Currently, we try to do a bunch of funkyness constraining download size
to print only when doing a -S/--sync operation. However, it is possible
we try to download packages on a -U/--upgrade operation, and we
currently won't show any itemized download sizes.
Fix this ommission by always including the download size stuff in the
built table rows; this column will be completely omitted anyway if there
are no values due to prior work in commit 33bb7dbd35
.
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
56f821b72a
commit
9e1a20022d
@ -793,7 +793,7 @@ void signature_display(const char *title, alpm_siglist_t *siglist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* creates a header row for use with table_display */
|
/* creates a header row for use with table_display */
|
||||||
static alpm_list_t *create_verbose_header(int dl_size)
|
static alpm_list_t *create_verbose_header(void)
|
||||||
{
|
{
|
||||||
alpm_list_t *res = NULL;
|
alpm_list_t *res = NULL;
|
||||||
char *str;
|
char *str;
|
||||||
@ -806,16 +806,14 @@ static alpm_list_t *create_verbose_header(int dl_size)
|
|||||||
res = alpm_list_add(res, str);
|
res = alpm_list_add(res, str);
|
||||||
str = _("Net Change");
|
str = _("Net Change");
|
||||||
res = alpm_list_add(res, str);
|
res = alpm_list_add(res, str);
|
||||||
if(dl_size) {
|
str = _("Download Size");
|
||||||
str = _("Download Size");
|
res = alpm_list_add(res, str);
|
||||||
res = alpm_list_add(res, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns package info as list of strings */
|
/* returns package info as list of strings */
|
||||||
static alpm_list_t *create_verbose_row(pm_target_t *target, int dl_size)
|
static alpm_list_t *create_verbose_row(pm_target_t *target)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
off_t size = 0;
|
off_t size = 0;
|
||||||
@ -852,16 +850,14 @@ static alpm_list_t *create_verbose_row(pm_target_t *target, int dl_size)
|
|||||||
pm_asprintf(&str, "%.2f %s", human_size, label);
|
pm_asprintf(&str, "%.2f %s", human_size, label);
|
||||||
ret = alpm_list_add(ret, str);
|
ret = alpm_list_add(ret, str);
|
||||||
|
|
||||||
if(dl_size) {
|
size = target->install ? alpm_pkg_download_size(target->install) : 0;
|
||||||
size = target->install ? alpm_pkg_download_size(target->install) : 0;
|
if(size != 0) {
|
||||||
human_size = humanize_size(size, 'M', 2, &label);
|
human_size = humanize_size(size, 'M', 2, &label);
|
||||||
if(size != 0) {
|
pm_asprintf(&str, "%.2f %s", human_size, label);
|
||||||
pm_asprintf(&str, "%.2f %s", human_size, label);
|
} else {
|
||||||
} else {
|
str = NULL;
|
||||||
str = strdup("");
|
|
||||||
}
|
|
||||||
ret = alpm_list_add(ret, str);
|
|
||||||
}
|
}
|
||||||
|
ret = alpm_list_add(ret, str);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -874,7 +870,6 @@ static void _display_targets(alpm_list_t *targets, int verbose)
|
|||||||
double size;
|
double size;
|
||||||
off_t isize = 0, rsize = 0, dlsize = 0;
|
off_t isize = 0, rsize = 0, dlsize = 0;
|
||||||
alpm_list_t *i, *rows = NULL, *names = NULL;
|
alpm_list_t *i, *rows = NULL, *names = NULL;
|
||||||
int show_dl_size = config->op == PM_OP_SYNC;
|
|
||||||
|
|
||||||
if(!targets) {
|
if(!targets) {
|
||||||
return;
|
return;
|
||||||
@ -898,7 +893,7 @@ static void _display_targets(alpm_list_t *targets, int verbose)
|
|||||||
for(i = targets; i; i = alpm_list_next(i)) {
|
for(i = targets; i; i = alpm_list_next(i)) {
|
||||||
pm_target_t *target = i->data;
|
pm_target_t *target = i->data;
|
||||||
|
|
||||||
rows = alpm_list_add(rows, create_verbose_row(target, show_dl_size));
|
rows = alpm_list_add(rows, create_verbose_row(target));
|
||||||
if(target->install) {
|
if(target->install) {
|
||||||
pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install),
|
pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install),
|
||||||
alpm_pkg_get_version(target->install));
|
alpm_pkg_get_version(target->install));
|
||||||
@ -917,7 +912,7 @@ static void _display_targets(alpm_list_t *targets, int verbose)
|
|||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if(verbose) {
|
if(verbose) {
|
||||||
alpm_list_t *header = create_verbose_header(show_dl_size);
|
alpm_list_t *header = create_verbose_header();
|
||||||
if(table_display(str, header, rows) != 0) {
|
if(table_display(str, header, rows) != 0) {
|
||||||
/* fallback to list display if table wouldn't fit */
|
/* fallback to list display if table wouldn't fit */
|
||||||
list_display(str, names);
|
list_display(str, names);
|
||||||
|
Loading…
Reference in New Issue
Block a user