From: Damien Riegel Date: Sat, 18 Feb 2017 18:41:19 +0000 (-0500) Subject: mx: remove `#ifdef USE_COMPRESSED` in mx_fastclose_mailbox X-Git-Tag: neomutt-20170414~41^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a12d989940542014762cb74f56e2362cc658348b;p=neomutt mx: remove `#ifdef USE_COMPRESSED` in mx_fastclose_mailbox Some code to cleanup compressed mailbox on close depends on an #ifdef block in mx_fastclose_mailbox, but this mailbox specific code should be implemented in the mx_ops' close function. This commit moves the call to `mutt_free_compress_info` in the mailbox close function, allowing us to mark it static and to remove the ifdef. --- diff --git a/compress.c b/compress.c index 68a54b7a9..39e525469 100644 --- a/compress.c +++ b/compress.c @@ -277,7 +277,7 @@ set_compress_info (CONTEXT *ctx) * mutt_free_compress_info - Frees the compress info members and structure. * @ctx: Mailbox to free compress_info for. */ -void +static void mutt_free_compress_info (CONTEXT *ctx) { COMPRESS_INFO *ci; @@ -618,7 +618,10 @@ close_mailbox (CONTEXT *ctx) struct mx_ops *ops = ci->child_ops; if (!ops) + { + mutt_free_compress_info (ctx); return -1; + } ops->close (ctx); @@ -634,35 +637,37 @@ close_mailbox (CONTEXT *ctx) { remove (ctx->path); } - - return 0; - } - - const char *append; - const char *msg; - - /* The file exists and we can append */ - if ((access (ctx->realpath, F_OK) == 0) && ci->append) - { - append = ci->append; - msg = _("Compressed-appending to %s..."); } else { - append = ci->close; - msg = _("Compressing %s..."); - } + const char *append; + const char *msg; - int rc = execute_command (ctx, append, msg); - if (rc == 0) - { - mutt_any_key_to_continue (NULL); - mutt_error (_("Error. Preserving temporary file: %s"), ctx->path); + /* The file exists and we can append */ + if ((access (ctx->realpath, F_OK) == 0) && ci->append) + { + append = ci->append; + msg = _("Compressed-appending to %s..."); + } + else + { + append = ci->close; + msg = _("Compressing %s..."); + } + + int rc = execute_command (ctx, append, msg); + if (rc == 0) + { + mutt_any_key_to_continue (NULL); + mutt_error (_("Error. Preserving temporary file: %s"), ctx->path); + } + else + remove (ctx->path); + + unlock_realpath (ctx); } - else - remove (ctx->path); - unlock_realpath (ctx); + mutt_free_compress_info (ctx); return 0; } diff --git a/compress.h b/compress.h index 0c545ee43..8a9608c1c 100644 --- a/compress.h +++ b/compress.h @@ -19,8 +19,6 @@ #ifndef _COMPRESS_H_ #define _COMPRESS_H_ -void mutt_free_compress_info (CONTEXT *ctx); - int mutt_comp_can_append (CONTEXT *ctx); int mutt_comp_can_read (const char *path); int mutt_comp_valid_command (const char *cmd); diff --git a/mx.c b/mx.c index 7624c5a66..dfddf9d64 100644 --- a/mx.c +++ b/mx.c @@ -739,10 +739,6 @@ void mx_fastclose_mailbox (CONTEXT *ctx) if (ctx->mx_ops) ctx->mx_ops->close (ctx); -#ifdef USE_COMPRESSED - mutt_free_compress_info (ctx); -#endif /* USE_COMPRESSED */ - if (ctx->subj_hash) hash_destroy (&ctx->subj_hash, NULL); if (ctx->id_hash)