[PATCH 2/2] Fix <get-attachment> to remove attachments upon compose abort.

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <[email protected]>
The files are copied to $tmpdraftdir, and are "owned" by the compose
process.  But they still had their unowned flag set.  So aborting the
compose would leave those files inside $tmpdraftdir.

Unset the flag so they are properly cleaned up.
---
 compose.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/compose.c b/compose.c
index 5cf1e31b..604cd185 100644
--- a/compose.c
+++ b/compose.c
@@ -1575,16 +1575,19 @@ int mutt_compose_menu(SEND_CONTEXT *sctx)
         CHECK_COUNT;
         if (menu->tagprefix)
         {
-          BODY *top;
-          for (top = msg->content; top; top = top->next)
-          {
-            if (top->tagged)
-              mutt_get_tmp_attachment(top);
-          }
+          for (i = 0; i < actx->idxlen; i++)
+            if (actx->idx[i]->content->tagged &&
+                (mutt_get_tmp_attachment(actx->idx[i]->content) == 0))
+            {
+              actx->idx[i]->unowned = 0;
+            }
           menu->redraw = REDRAW_FULL;
         }
         else if (mutt_get_tmp_attachment(CURATTACH->content) == 0)
+        {
+          CURATTACH->unowned = 0;
           menu->redraw = REDRAW_CURRENT;
+        }
 
         /* No send2hook since this doesn't change the message. */
         break;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.