diff options
author | Kevin McCarthy <kevin@8t8.us> | 2016-11-13 20:02:36 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2016-11-13 20:02:36 -0800 |
commit | aab2d75f3eaf75ec4b39a4b8e36f7d4270022c1d (patch) | |
tree | 31554a371a6441e345105d78069b02a727b96d01 /compress.c | |
parent | aa8f2cdf2f95bde8087887b2e439677056ce0efd (diff) |
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.
Diffstat (limited to 'compress.c')
-rw-r--r-- | compress.c | 30 |
1 files changed, 17 insertions, 13 deletions
@@ -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) |