pidgin: 20320727: ft: Set completion (for receiving) *afte...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Thu Aug 13 00:13:32 EDT 2009


-----------------------------------------------------------------
Revision: 20320727f6c8f5a4a4b7b8c0f65c74a57ada1e15
Ancestor: fb0e9217da1d198efe214766b21e0152c6a17380
Author: darkrain42 at pidgin.im
Date: 2009-08-13T04:05:13
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/20320727f6c8f5a4a4b7b8c0f65c74a57ada1e15

Modified files:
        libpurple/ft.c

ChangeLog: 

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".

-------------- next part --------------
============================================================
--- libpurple/ft.c	0b75c2b2b36c61bbc68e0843518cf1a00e708d81
+++ libpurple/ft.c	3862c5eedf963650e7ef16da58282942dab44e61
@@ -926,9 +926,6 @@ purple_xfer_read(PurpleXfer *xfer, gucha
 
 	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 @@ purple_xfer_read(PurpleXfer *xfer, gucha
 			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 @@ do_transfer(PurpleXfer *xfer)
 				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);


More information about the Commits mailing list