summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2008-02-23 01:17:59 +0000
committerJason Woodward2008-02-23 01:17:59 +0000
commit34c5a086823e97f07893fc646f529ae2f30e564c (patch)
treec34bfba80f13e753d5db30e452b7324440953b30
parentca8b99b71bb4f3161799b0af63b702116ca96506 (diff)
downloadslapt-get-0.9.12d.tar.gz
added download count notification while downloading packges (Sergio)0.9.12d
-rw-r--r--ChangeLog3
-rw-r--r--src/curl.c8
-rw-r--r--src/curl.h2
-rw-r--r--src/transaction.c18
4 files changed, 24 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6545af4..cf6fdd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
-0.9.12d Dec 09, 2007
+0.9.12d Feb 22, 2008
+ * Added download count notification while downloading packages (Sergio)
* Fix for parsing dependencies that have a dash in the package name
0.9.12c Oct 27, 2007
diff --git a/src/curl.c b/src/curl.c
index 873d69c..6adcfa7 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -187,7 +187,7 @@ const char *slapt_get_mirror_data_from_source(FILE *fh,
}
const char *slapt_download_pkg(const slapt_rc_config *global_config,
- slapt_pkg_info_t *pkg)
+ slapt_pkg_info_t *pkg, const char *note)
{
FILE *fh = NULL;
char *file_name = NULL;
@@ -235,6 +235,10 @@ const char *slapt_download_pkg(const slapt_rc_config *global_config,
}
if (global_config->progress_cb == NULL) {
+
+ if (note != NULL)
+ printf("%s ", note);
+
printf(gettext("Get %s %s %s [%.1f%s]..."),
pkg->mirror,pkg->name,pkg->version,
( dl_total_size > 1024 ) ? dl_total_size / 1024.0 : dl_total_size,
@@ -283,7 +287,7 @@ const char *slapt_download_pkg(const slapt_rc_config *global_config,
if (global_config->retry > 1)
return curl_easy_strerror(dl_return);
else
- return slapt_download_pkg(global_config,pkg);
+ return slapt_download_pkg(global_config,pkg, note);
} else {
fclose(fh);
diff --git a/src/curl.h b/src/curl.h
index a3e38ce..44256c2 100644
--- a/src/curl.h
+++ b/src/curl.h
@@ -17,7 +17,7 @@ const char *slapt_get_mirror_data_from_source(FILE *fh,
download pkg, calls download_data. returns error on failure.
*/
const char *slapt_download_pkg(const slapt_rc_config *global_config,
- slapt_pkg_info_t *pkg);
+ slapt_pkg_info_t *pkg, const char *note);
/*
this is the default progress callback if global_config->progress_cb == NULL
diff --git a/src/transaction.c b/src/transaction.c
index c50a54e..11ef361 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -18,6 +18,8 @@
#include "main.h"
+#define SLAPT_PKG_DL_NOTE_LEN 16
+
static slapt_queue_t *slapt_queue_init(void);
static void queue_add_install(slapt_queue_t *t, slapt_pkg_info_t *p);
static void queue_add_upgrade(slapt_queue_t *t, slapt_pkg_upgrade_t *p);
@@ -59,10 +61,11 @@ slapt_transaction_t *slapt_init_transaction(void)
int slapt_handle_transaction (const slapt_rc_config *global_config,
slapt_transaction_t *tran)
{
- unsigned int i;
+ unsigned int i, pkg_dl_count = 0, dl_counter = 0;
double download_size = 0;
double already_download_size = 0;
double uncompressed_size = 0;
+ char dl_note[SLAPT_PKG_DL_NOTE_LEN];
/* show unmet dependencies */
if (tran->missing_err->err_count > 0) {
@@ -358,12 +361,17 @@ int slapt_handle_transaction (const slapt_rc_config *global_config,
return 0;
}
+ pkg_dl_count = tran->install_pkgs->pkg_count + tran->upgrade_pkgs->pkg_count;
+
/* download pkgs */
for (i = 0; i < tran->install_pkgs->pkg_count; ++i) {
unsigned int retry_count, failed = 1;
+ ++dl_counter;
+ snprintf(dl_note, SLAPT_PKG_DL_NOTE_LEN, "%d/%d", dl_counter, pkg_dl_count);
+
for (retry_count = 0; retry_count < global_config->retry; ++retry_count) {
- const char *err = slapt_download_pkg(global_config,tran->install_pkgs->pkgs[i]);
+ const char *err = slapt_download_pkg(global_config,tran->install_pkgs->pkgs[i], dl_note);
if (err) {
fprintf(stderr,gettext("Failed to download: %s\n"),err);
failed = 1;
@@ -379,8 +387,12 @@ int slapt_handle_transaction (const slapt_rc_config *global_config,
for (i = 0; i < tran->upgrade_pkgs->pkg_count; ++i) {
unsigned int retry_count, failed = 1;
+
+ ++dl_counter;
+ snprintf(dl_note, SLAPT_PKG_DL_NOTE_LEN, "%d/%d", dl_counter, pkg_dl_count);
+
for (retry_count = 0; retry_count < global_config->retry; ++retry_count) {
- const char *err = slapt_download_pkg(global_config,tran->upgrade_pkgs->pkgs[i]->upgrade);
+ const char *err = slapt_download_pkg(global_config,tran->upgrade_pkgs->pkgs[i]->upgrade, dl_note);
if (err) {
fprintf(stderr,gettext("Failed to download: %s\n"),err);
failed = 1;