Fix bug #3246 ‘attachment open: "remember this" ignored if ~/.mailcap does not exist’
authorRicardo Mones <ricardo@mones.org>
Tue, 19 Aug 2014 15:17:30 +0000 (17:17 +0200)
committerRicardo Mones <ricardo@mones.org>
Tue, 19 Aug 2014 15:55:31 +0000 (17:55 +0200)
Add also a warning if intermediate file cannot be created.

src/common/utils.c

index 9b9b1f8..2e41793 100644 (file)
@@ -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);