changeset 28247:e30de9ebfa69

ft: Set completion (for receiving) *after* writing the file. kenshin in #pidgin correctly pointed out this could have falsely failed to write all the data to the file and still declared the transfer "Complete".
author Paul Aurich <paul@darkrain42.org>
date Thu, 13 Aug 2009 04:05:13 +0000
parents c93ed4d7cabe
children 56770cc3287d e4b0bf56667f
files libpurple/ft.c
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Thu Aug 13 03:28:38 2009 +0000
+++ b/libpurple/ft.c	Thu Aug 13 04:05:13 2009 +0000
@@ -926,9 +926,6 @@
 
 	if (xfer->ops.read != NULL)	{
 		r = (xfer->ops.read)(buffer, xfer);
-		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 {
 		*buffer = g_malloc0(s);
@@ -938,9 +935,6 @@
 			r = 0;
 		else if (r < 0)
 			r = -1;
-		else 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)
 			r = -1;
 	}
@@ -1004,6 +998,10 @@
 				g_free(buffer);
 				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);