]> granicus.if.org Git - neomutt/commitdiff
mx: remove `#ifdef USE_COMPRESSED` in mx_fastclose_mailbox
authorDamien Riegel <damien.riegel@gmail.com>
Sat, 18 Feb 2017 18:41:19 +0000 (13:41 -0500)
committerRichard Russon <rich@flatcap.org>
Tue, 7 Mar 2017 12:08:04 +0000 (12:08 +0000)
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.

compress.c
compress.h
mx.c

index 68a54b7a98808b67797fbed115739ad19549e2f5..39e525469f5010125329dfe8f9e42724f6f88a7c 100644 (file)
@@ -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;
 }
index 0c545ee43cd1d88f3a5813f42163a2deef3429a9..8a9608c1cb27feb8829a071d0e7d2eaa0bb5e1aa 100644 (file)
@@ -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 7624c5a66ea81405cc2320370ad8dd322a6954f8..dfddf9d64b629dc031a5a1507b02e61b72180ed9 100644 (file)
--- 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)