Blame SOURCES/evolution-ews-3.22.6-truncate-before-resave-mail.patch

974103
diff -up evolution-ews-3.22.6/src/camel/camel-ews-folder.c.truncate-before-resave-mail evolution-ews-3.22.6/src/camel/camel-ews-folder.c
974103
--- evolution-ews-3.22.6/src/camel/camel-ews-folder.c.truncate-before-resave-mail	2017-03-22 13:00:18.239073297 +0100
974103
+++ evolution-ews-3.22.6/src/camel/camel-ews-folder.c	2017-03-22 13:00:18.242073297 +0100
974103
@@ -746,6 +746,26 @@ camel_ews_folder_get_message (CamelFolde
974103
 			/* Ignore errors here, it's nothing fatal in this case */
974103
 			cache_stream = ews_data_cache_get (ews_folder->cache, "cur", uid, NULL);
974103
 			if (cache_stream) {
974103
+				GIOStream *iostream;
974103
+
974103
+				/* Truncate the stream first, in case the message will be shorter
974103
+				   than the one received from the server */
974103
+				iostream = camel_stream_ref_base_stream (cache_stream);
974103
+				if (iostream) {
974103
+					GOutputStream *output_stream;
974103
+
974103
+					output_stream = g_io_stream_get_output_stream (iostream);
974103
+					if (G_IS_SEEKABLE (output_stream)) {
974103
+						GSeekable *seekable = G_SEEKABLE (output_stream);
974103
+
974103
+						if (g_seekable_can_truncate (seekable)) {
974103
+							g_seekable_truncate (seekable, 0, NULL, NULL);
974103
+						}
974103
+					}
974103
+
974103
+					g_object_unref (iostream);
974103
+				}
974103
+
974103
 				camel_data_wrapper_write_to_stream_sync (CAMEL_DATA_WRAPPER (message), cache_stream, cancellable, NULL);
974103
 				g_object_unref (cache_stream);
974103
 			}