[balsa/64-save-empty-attachment] balsa-mime-widget-callbacks: Handle empty part
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/64-save-empty-attachment] balsa-mime-widget-callbacks: Handle empty part
- Date: Fri, 14 Jan 2022 18:21:16 +0000 (UTC)
commit 646ec8431f931811ccc50856a90a05a93065b56b
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Fri Jan 14 13:01:58 2022 -0500
balsa-mime-widget-callbacks: Handle empty part
When saving an attachment to a file, use libbalsa_vfs_ensure_file_exists()
to make sure that the file is created before saving the attachment's content
to it.
As noted in https://gitlab.gnome.org/GNOME/balsa/-/issues/64, when
g_mime_stream_write_to_stream() writes to a destination file that does
not previously exist, it creates it only if content is written to it. So
saving an empty attachment did not create the corresponding empty file.
Fixes #64
src/balsa-mime-widget-callbacks.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index 895e5a844..30ea58332 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -153,6 +153,18 @@ balsa_mime_widget_ctx_menu_save(GtkWidget * parent_widget,
} else
do_save = TRUE;
+ if (do_save) {
+ /* Make sure the file is created.
+ * https://gitlab.gnome.org/GNOME/balsa/-/issues/64 */
+ if (!libbalsa_vfs_ensure_file_exists(save_file, &err)) {
+ balsa_information(LIBBALSA_INFORMATION_ERROR,
+ _("Could not save %s: %s"),
+ file_uri, err ? err->message : "Unknown error");
+ g_clear_error(&err);
+ do_save = FALSE;
+ }
+ }
+
/* save the file */
if (do_save) {
if (!libbalsa_message_body_save_vfs(mime_body, save_file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]