From b37e21002c06238c59aecc03192aa9d79200647e Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 13 Nov 2016 20:02:36 -0800 Subject: [PATCH] Compress: check mailbox type if possible when appending. If an append hook isn't defined, then mutt has to decompress the mailbox. In that case, we can check the type of the decompressed mailbox instead of defaulting to DefaultMagic. --- compress.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/compress.c b/compress.c index ae8d563b2..0df85aedb 100644 --- a/compress.c +++ b/compress.c @@ -541,22 +541,9 @@ open_append_mailbox (CONTEXT *ctx, int flags) goto oa_fail1; } - ctx->magic = DefaultMagic; - /* We can only deal with mbox and mmdf mailboxes */ - if ((ctx->magic != MUTT_MBOX) && (ctx->magic != MUTT_MMDF)) - goto oa_fail1; - if (setup_paths (ctx) != 0) goto oa_fail2; - ctx->mx_ops = &mx_comp_ops; - ci->child_ops = mx_get_ops (ctx->magic); - if (!ci->child_ops) - { - mutt_error (_("Can't find mailbox ops for mailbox type %d"), ctx->magic); - goto oa_fail2; - } - /* Lock the realpath for the duration of the append. * It will be unlocked in the close */ if (!lock_realpath (ctx, 1)) @@ -574,6 +561,23 @@ open_append_mailbox (CONTEXT *ctx, int flags) mutt_error (_("Compress command failed: %s"), ci->open); goto oa_fail2; } + ctx->magic = mx_get_magic (ctx->path); + } + else + ctx->magic = DefaultMagic; + + /* We can only deal with mbox and mmdf mailboxes */ + if ((ctx->magic != MUTT_MBOX) && (ctx->magic != MUTT_MMDF)) + { + mutt_error (_("Unsupported mailbox type for appending.")); + goto oa_fail2; + } + + ci->child_ops = mx_get_ops (ctx->magic); + if (!ci->child_ops) + { + mutt_error (_("Can't find mailbox ops for mailbox type %d"), ctx->magic); + goto oa_fail2; } if (ci->child_ops->open_append (ctx, flags) != 0) -- 2.40.0