changeset 29519:18667ce1f55d

The current behavior of libpurple reports completions of a file transfer too soon. The -completed signal is emitted before the sent bytes counter is updated which means anything relaying on that will get confused (the file transfer is indeed completed) but the number of transferred bytes will be incorrect at the moment of the signal emission. This patch aims to correct that. Fixes #10119. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author foufou33@gmail.com
date Mon, 12 Oct 2009 18:48:19 +0000
parents 51c5cbc0d325
children 4558a09a08c7
files libpurple/ft.c
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Mon Oct 12 18:41:51 2009 +0000
+++ b/libpurple/ft.c	Mon Oct 12 18:48:19 2009 +0000
@@ -981,8 +981,6 @@
 		r = write(xfer->fd, buffer, s);
 		if (r < 0 && errno == EAGAIN)
 			r = 0;
-		if ((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer))
-			purple_xfer_set_completed(xfer, TRUE);
 	}
 
 	return r;
@@ -1013,9 +1011,6 @@
 				return;
 			}
 
-			if ((purple_xfer_get_size(xfer) > 0) &&
-				((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer)))
-				purple_xfer_set_completed(xfer, TRUE);
 		} else if(r < 0) {
 			purple_xfer_cancel_remote(xfer);
 			g_free(buffer);
@@ -1129,8 +1124,11 @@
 				purple_xfer_get_progress(xfer));
 	}
 
-	if (purple_xfer_is_completed(xfer))
+	if ((purple_xfer_get_size(xfer) > 0) &&		
+              	((purple_xfer_get_bytes_sent(xfer)) >= purple_xfer_get_size(xfer))) {		
+		purple_xfer_set_completed(xfer, TRUE);
 		purple_xfer_end(xfer);
+	}
 }
 
 static void