aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorDavid Dykstra <dwd@samba.org>1999-02-18 17:23:44 +0000
committerDavid Dykstra <dwd@samba.org>1999-02-18 17:23:44 +0000
commit17d31b380b7c748837b30e7e0c54ab17974f7ab6 (patch)
tree708bdebe1925424fe902527b5644d00f2f3210ff /main.c
parenta8b9d4edec745757d34a10be0f6956c0609c2284 (diff)
downloadandroid_external_rsync-17d31b380b7c748837b30e7e0c54ab17974f7ab6.tar.gz
android_external_rsync-17d31b380b7c748837b30e7e0c54ab17974f7ab6.tar.bz2
android_external_rsync-17d31b380b7c748837b30e7e0c54ab17974f7ab6.zip
Changed --stats implementation to work without -v in only these two
situations: 1. the client is the receiver of files. Can't do it otherwise yet because without -v the bytes written from the sender's generator process will not be counted. 2. both the remote and local protocol versions are >=20. I did not change the protocol version yet because it is such a minor change that it isn't worth it, although I did test it with the protocol version set to 20. If neither of the situations hold, it prints a message saying to use -v.
Diffstat (limited to 'main.c')
-rw-r--r--main.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/main.c b/main.c
index 56a078bf..2846f881 100644
--- a/main.c
+++ b/main.c
@@ -34,14 +34,18 @@ static void report(int f)
extern int am_sender;
extern int am_daemon;
extern int do_stats;
+ extern int remote_version;
+ int send_stats;
if (am_daemon) {
log_exit(0, __FILE__, __LINE__);
if (f == -1 || !am_sender) return;
}
+ send_stats = verbose ||
+ ((remote_version >= 20) && (PROTOCOL_VERSION >= 20));
if (am_server) {
- if (verbose && am_sender) {
+ if (am_sender && send_stats) {
int64 w;
/* store total_written in a temporary
because write_longint changes it */
@@ -55,12 +59,7 @@ static void report(int f)
/* this is the client */
- if (!am_sender && verbose) {
- /* note that if (!verbose && do_stats) then these values will
- be taken from the receiver side's copy. The total size
- is identical but the bytes read and written are slightly
- different. It's done this way to avoid modifying the
- protocol to support --stats without -v. */
+ if (!am_sender && send_stats) {
int64 r;
stats.total_written = read_longint(f);
/* store total_read in a temporary, read_longint changes it */
@@ -70,6 +69,12 @@ static void report(int f)
}
if (do_stats) {
+ if (!am_sender && !send_stats) {
+ /* missing the bytes written by the generator */
+ rprintf(FINFO, "\nCannot show stats as receiver because protocol version is less than 20\n");
+ rprintf(FINFO, "Use --stats -v to show stats\n");
+ return;
+ }
rprintf(FINFO,"\nNumber of files: %d\n", stats.num_files);
rprintf(FINFO,"Number of files transferred: %d\n",
stats.num_transferred_files);