commit 7a114d508a42a8d7282011a2c46cf8aa7aa4eaef
parent 9166dc63e4d2f3f4d62293b48706cfa9b9a0afc1
Author: Ricardo Mones <ricardo@mones.org>
Date: Tue, 19 Aug 2014 17:17:30 +0200
Fix bug #3246 ‘attachment open: "remember this" ignored if ~/.mailcap does not exist’
Add also a warning if intermediate file cannot be created.
Diffstat:
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/common/utils.c b/src/common/utils.c
@@ -4805,13 +4805,25 @@ void mailcap_update_default(const gchar *type, const gchar *command)
gboolean err = FALSE;
if (!fp) {
- g_free(path);
- g_free(outpath);
- return;
+ fp = g_fopen(path, "a");
+ if (!fp) {
+ g_warning("failed to create file %s\n", path);
+ g_free(path);
+ g_free(outpath);
+ return;
+ }
+ fp = g_freopen(path, "rb", fp);
+ if (!fp) {
+ g_warning("failed to reopen file %s\n", path);
+ g_free(path);
+ g_free(outpath);
+ return;
+ }
}
outfp = g_fopen(outpath, "wb");
if (!outfp) {
+ g_warning("failed to create file %s\n", outpath);
g_free(path);
g_free(outpath);
fclose(fp);