summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2012-10-19 19:23:32 -0700
committerBen Straub <bs@github.com>2012-10-19 19:36:23 -0700
commit7bcd9e23e8f64c8622e9213ee0fa3d75d058053b (patch)
tree42d73408bb7e3df8d487d38ecfaf0efb9c0531c6 /examples
parent25e8b20169a6f6919ad49cf32220975ab96b35c8 (diff)
downloadlibgit2-7bcd9e23e8f64c8622e9213ee0fa3d75d058053b.tar.gz
gitno_buffer: callback on each packet
The fetch code takes advantage of this to implement a progress callback every 100kb of transfer.
Diffstat (limited to 'examples')
-rw-r--r--examples/network/clone.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/network/clone.c b/examples/network/clone.c
index fd30bca5b..5ad9330b9 100644
--- a/examples/network/clone.c
+++ b/examples/network/clone.c
@@ -18,10 +18,11 @@ static void print_progress(const progress_data *pd)
int network_percent = (100*pd->fetch_progress.received) / pd->fetch_progress.total;
int index_percent = (100*pd->fetch_progress.processed) / pd->fetch_progress.total;
int checkout_percent = (int)(100.f * pd->checkout_progress);
- printf("net %3d%% / idx %3d%% / chk %3d%% %50s\r",
- network_percent, index_percent, checkout_percent, pd->path);
+ int kbytes = pd->fetch_progress.bytes / 1024;
+ printf("net %3d%% (%6d kb) / idx %3d%% / chk %3d%% %50s\n",
+ network_percent, kbytes, index_percent, checkout_percent, pd->path);
/*
- printf("net %5d /%5d – idx %5d /%5d – chk %.04f %20s\r",
+ printf("net %5d /%5d – idx %5d /%5d – chk %.04f %20s\n",
pd->fetch_progress.received, pd->fetch_progress.total,
pd->fetch_progress.processed, pd->fetch_progress.total,
pd->checkout_progress, pd->path);