(Patch) Some fixes for detecting errors in vfs stream transfers



	Hi,

	This patch adds some codepaths to detect errors tranferring streams:
	* Now we detect in tny_camel_mime_part_get_decoded_stream_default if we
got an error constructing the stream in camel.
	* Now we also return -1 in tny_vfs_stream_read if there was an error
reading the stream.

	Changelog entry:
	* libtinymail-camel/tny-camel-mime-part.c
	(tny_camel_get_decoded_stream_default): now we detect errors getting
	the decoded stream from camel.
	* libtinymail-gnomevfs/tny-vfs-stream.c (tny_vfs_stream_read):
	return -1 if there was an error reading from the vfs stream.


-- 
José Dapena Paz <jdapena igalia com>
Igalia
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 3593)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2008-04-16  José Dapena Paz  <jdapena igalia com>
+
+	* libtinymail-camel/tny-camel-mime-part.c
+	(tny_camel_get_decoded_stream_default): now we detect errors getting
+	the decoded stream from camel.
+	* libtinymail-gnomevfs/tny-vfs-stream.c (tny_vfs_stream_read):
+	return -1 if there was an error reading from the vfs stream.
+
 2008-04-15  Philip Van Hoof <pvanhoof gnome org>
 
 	* Fixed alerts when get-msg-async takes place to have their account
Index: libtinymail-camel/tny-camel-mime-part.c
===================================================================
--- libtinymail-camel/tny-camel-mime-part.c	(revision 3593)
+++ libtinymail-camel/tny-camel-mime-part.c	(working copy)
@@ -925,6 +925,7 @@
 	CamelDataWrapper *wrapper;
 	CamelMedium *medium;
 	CamelStream *stream = camel_stream_mem_new ();
+	gssize bytes = -1;
 
 	g_mutex_lock (priv->part_lock);
 	medium =  CAMEL_MEDIUM (priv->part);
@@ -943,15 +944,17 @@
 		camel_stream_reset (wrapper->stream);
 
 		if (camel_content_type_is (wrapper->mime_type, "text", "*"))
-			camel_stream_format_text (wrapper, stream);
+			bytes = camel_stream_format_text (wrapper, stream);
 		else
-			camel_data_wrapper_decode_to_stream (wrapper, stream);
+			bytes = camel_data_wrapper_decode_to_stream (wrapper, stream);
 	}
 
-	retval = TNY_STREAM (tny_camel_stream_new (stream));
+	if (bytes >= 0) {
+		retval = TNY_STREAM (tny_camel_stream_new (stream));
+		tny_stream_reset (retval);
+	}
+
 	camel_object_unref (stream);
-
-	tny_stream_reset (retval);
 	camel_object_unref (medium);
 
 	return retval;
Index: libtinymail-gnomevfs/tny-vfs-stream.c
===================================================================
--- libtinymail-gnomevfs/tny-vfs-stream.c	(revision 3593)
+++ libtinymail-gnomevfs/tny-vfs-stream.c	(working copy)
@@ -178,7 +178,9 @@
 	if (nread > 0 && result == GNOME_VFS_OK)
 		priv->position += nread;
 	else { 
-		if (nread == 0)
+		if ((result != GNOME_VFS_OK) && (result != GNOME_VFS_ERROR_EOF))
+			nread = -1;
+		else if (nread == 0)
 			priv->eos = TRUE;
 		tny_vfs_stream_set_errno (result);
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]