Fixes NB76286
[modest] / src / maemo / modest-maemo-utils.c
index 656202d..a28a8d9 100644 (file)
@@ -299,15 +299,26 @@ modest_maemo_utils_create_temp_stream (const gchar *orig_name, const gchar *hash
                return NULL;
        }
 
-       /* try to write the file there */
        filepath = g_strconcat (tmpdir, "/", orig_name, NULL);
-       fd = g_open (filepath, O_CREAT|O_WRONLY|O_TRUNC, 0644);
-       if (fd == -1) {
-               g_warning ("%s: failed to create '%s': %s",
-                          __FUNCTION__, filepath, g_strerror(errno));
+       /* don't overwrite if it already exists, even if it is writable */
+       if (modest_maemo_utils_file_exists (filepath)) {
+               if (path!=NULL) {
+                       *path = filepath;
+               } else {
+                       g_free (filepath);
+               }
                g_free (tmpdir);
-               g_free (filepath);
                return NULL;
+       } else {
+               /* try to write the file there */
+               fd = g_open (filepath, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+               if (fd == -1) {
+                       g_warning ("%s: failed to create '%s': %s",
+                                       __FUNCTION__, filepath, g_strerror(errno));                     
+                       g_free (filepath);
+                       g_free (tmpdir);
+                       return NULL;
+               }
        }
 
        g_free (tmpdir);
@@ -692,8 +703,8 @@ modest_maemo_open_mcc_mapping_file (void)
        FILE* result;
        
        const gchar* path;
-       const gchar* path1 = MODEST_OPERATOR_WIZARD_PROVIDER_DATA_DIR;
-       const gchar* path2 = MODEST_PROVIDER_DATA_DIR;
+       const gchar* path1 = MODEST_OPERATOR_WIZARD_MCC_MAPPING;
+       const gchar* path2 = MODEST_MCC_MAPPING;
        
        if (access(path1, R_OK) == 0) 
                path = path1;