From: Kevin McCarthy Date: Mon, 14 Nov 2016 04:02:36 +0000 (-0800) Subject: Compress: check mailbox type if possible when appending. X-Git-Tag: neomutt-20161126~16^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e40967fb19668046db9ebb25cb81da41fff465c;p=neomutt 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. --- 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)