]> granicus.if.org Git - mutt/commitdiff
Create mh_sequences files when they don't exist. Suggested by
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 1 Oct 2001 09:58:49 +0000 (09:58 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 1 Oct 2001 09:58:49 +0000 (09:58 +0000)
TAKIZAWA Takashi <taki@luna.email.ne.jp>.

mh.c

diff --git a/mh.c b/mh.c
index aa6a2d286a18f281161c35d76a8c21917fe21444..5ff5b406e59c501de52b4110811ee6667974ca85 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -1240,11 +1240,30 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
     strfcpy(buf, ctx->path, sizeof(buf));
     if(stat(buf, &st) == -1)
       return -1;
-    
+
+    /* create .mh_sequences when there isn't one. */
     snprintf (buf, sizeof (buf), "%s/.mh_sequences", ctx->path);
     if (stat (buf, &st_cur) == -1)
-      modified = 1;
-    
+    {
+      if (errno == ENOENT)
+      {
+       char *tmp;
+       FILE *fp = NULL;
+
+       if (mh_mkstemp (ctx, &fp, &tmp) == 0)
+       {
+         safe_fclose (&fp);
+         if (safe_rename (tmp, buf) == -1)
+           unlink (tmp);
+         safe_free ((void **) &tmp);
+       }
+       
+       if (stat (buf, &st_cur) == -1)
+         modified = 1;
+      }
+      else
+       modified = 1;
+    }
   }
   else if(ctx->magic == M_MAILDIR)
   {