[geary: 13/23] Flush sinks of GMime filter streams



commit 5069556a7e85ad918a20329d5f5b2ead51560e9c
Author: Torben <torben letorbi gmail com>
Date:   Fri Dec 13 21:35:33 2019 +0100

    Flush sinks of GMime filter streams

 src/engine/rfc822/rfc822-message.vala |  5 ++++-
 src/engine/rfc822/rfc822-part.vala    | 14 ++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index 4f56e270..6e5712b2 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -1114,9 +1114,12 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet {
         }
 
         if (message.write_to_stream(Geary.RFC822.get_format_options(), stream_filter) < 0)
-            throw new RFC822Error.FAILED("Unable to write RFC822 message to memory buffer");
+            throw new RFC822Error.FAILED("Unable to write RFC822 message to filter stream");
 
         if (stream_filter.flush() != 0)
+            throw new RFC822Error.FAILED("Unable to flush RFC822 message to memory stream");
+
+        if (stream.flush() != 0)
             throw new RFC822Error.FAILED("Unable to flush RFC822 message to memory buffer");
 
         return new Memory.ByteBuffer.from_byte_array(byte_array);
diff --git a/src/engine/rfc822/rfc822-part.vala b/src/engine/rfc822/rfc822-part.vala
index 6d0521d1..58c58ff0 100644
--- a/src/engine/rfc822/rfc822-part.vala
+++ b/src/engine/rfc822/rfc822-part.vala
@@ -226,12 +226,18 @@ public class Geary.RFC822.Part : Object {
                 filter.add(new Geary.RFC822.FilterBlockquotes());
             }
 
-            wrapper.write_to_stream(filter);
-            filter.flush();
+            if (wrapper.write_to_stream(filter) < 0)
+                throw new RFC822Error.FAILED("Unable to write textual RFC822 part to filter stream");
+            if (filter.flush() != 0)
+                throw new RFC822Error.FAILED("Unable to flush textual RFC822 part to destination stream");
+            if (destination.flush() != 0)
+                throw new RFC822Error.FAILED("Unable to flush textual RFC822 part to destination");
         } else {
             // Keep as binary
-            wrapper.write_to_stream(destination);
-            destination.flush();
+            if (wrapper.write_to_stream(destination) < 0)
+                throw new RFC822Error.FAILED("Unable to write binary RFC822 part to destination stream");
+            if (destination.flush() != 0)
+                throw new RFC822Error.FAILED("Unable to flush binary RFC822 part to destination");
         }
     }
 


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