From d5e9ff04e4f832900e77a2bf7733b17d9707e744 Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Wed, 13 May 2009 12:21:43 +0200 Subject: [PATCH] Actually reopen mbox/mmdf files in case we find modifications. Closes #2725. Since the file is changed while we have it open in ctx->fp, we likely get wrong information when parsing the mailbox. Now we explicitely close and (re)open it. --- mbox.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/mbox.c b/mbox.c index 844da877d..bab8ce9ee 100644 --- a/mbox.c +++ b/mbox.c @@ -1109,17 +1109,13 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint) { case M_MBOX: case M_MMDF: - if (fseek (ctx->fp, 0, SEEK_SET) != 0) - { - dprint (1, (debugfile, "mutt_reopen_mailbox: fseek() failed\n")); - rc = -1; - } - else - { - cmp_headers = mbox_strict_cmp_headers; - rc = ((ctx->magic == M_MBOX) ? mbox_parse_mailbox - : mmdf_parse_mailbox) (ctx); - } + cmp_headers = mbox_strict_cmp_headers; + safe_fclose (&ctx->fp); + if (!(ctx->fp = safe_fopen (ctx->path, "r"))) + rc = -1; + else + rc = ((ctx->magic == M_MBOX) ? mbox_parse_mailbox + : mmdf_parse_mailbox) (ctx); break; default: -- 2.40.0