[Maildir] Create the 'tmp' directory, if missing
authorMilan Crha <mcrha@redhat.com>
Mon, 12 Aug 2013 08:21:08 +0000 (10:21 +0200)
committerMilan Crha <mcrha@redhat.com>
Mon, 12 Aug 2013 08:21:08 +0000 (10:21 +0200)
If a folder's directory is missing 'tmp' sub-directory, but it has
all the other 'cur' and 'new' directories, then try to create
the 'tmp' to get all three required directories.

It's because some backup tools can drop the 'tmp' directories.

This was reported as: https://bugzilla.redhat.com/show_bug.cgi?id=995702

camel/providers/local/camel-maildir-store.c

index 53d0230..49395f7 100644 (file)
@@ -506,9 +506,11 @@ scan_fi (CamelStore *store,
        cur = g_build_filename (path, dir_name, "cur", NULL);
        new = g_build_filename (path, dir_name, "new", NULL);
 
-       if (!(g_stat (tmp, &st) == 0 && S_ISDIR (st.st_mode)
-             && g_stat (cur, &st) == 0 && S_ISDIR (st.st_mode)
-             && g_stat (new, &st) == 0 && S_ISDIR (st.st_mode)))
+       if (!(g_stat (cur, &st) == 0 && S_ISDIR (st.st_mode)
+             && g_stat (new, &st) == 0 && S_ISDIR (st.st_mode)
+             /* Create 'tmp' dir on demand, if other directories are there,
+                because some backup tools can drop the 'tmp' directory. */
+             && ((g_stat (tmp, &st) == 0 && S_ISDIR (st.st_mode)) || g_mkdir (tmp, 0700) == 0)))
                fi->flags |= CAMEL_FOLDER_NOSELECT;
 
        g_free (new);