From ec640c6a157053c99e417eb763a7d99353cc3b5a Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Mon, 1 Oct 2001 09:58:49 +0000 Subject: [PATCH] Create mh_sequences files when they don't exist. Suggested by TAKIZAWA Takashi . --- mh.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/mh.c b/mh.c index aa6a2d28..5ff5b406 100644 --- 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) { -- 2.40.0