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

Alejandro Colomar via Mutt-dev <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <ao1zvv6L9oF2XvaV@devuan>
Hi Kevin,

> Date: 2026-08-25 18:00:25+0800
> From: "Kevin J. McCarthy" <[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;
> +            }

This for loop feels quite weird (due to braces).  How about reversing
one condition to split them?

	for (i = 0; i < actx->idxlen; i++)
	{
	  if (!actx->idx[i]->content->tagged)
	    continue;
	  if (mutt_get_tmp_attachment(actx->idx[i]->content) == 0)
	    actx->idx[i]->unowned = 0;
	}


Have a lovely day!
Alex

>            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
> 

-- 
<https://www.alejandro-colomar.es>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmqNdN4ACgkQ64mZXMKQ
wqlkIBAAhGvylpbPUe4GT4HclY8F5mnxvVMcmSuHLj13fsQEmQ6C8TDzSS84aoUK
b9QV3BKRp3bzIcP0b0l1qQLre6Z5yDTTqzuELCHZ0yxhflzxz6uQuvegttqdrZGC
sWehMQosrbgbwHd/XLpfbeittoG7Upd5x/59vEebsthAMsGX3McnyXj5eCLVXC6W
Py+sFlWCpfDVD2UFYkCe09X0H20oy2i9lkIwynbujFBg4oe/GvcNJ+52vW/DvEwH
faBvi9njJEpxrNMP8lbp09XviyTMa/ixHig3uJ/XNEcgi7TuKwQjKhGzm4/o7c8W
APsQcxd2wxesH843BYzmYAL8wHupjXXkBlytTXm8T4xhn8mR2ol9od8zuPGodKiK
+wyBThS3Ok+ohveU1vhljcV2jxyReehIwTUHcq2OPiqGVchSDut7iqNm2Iy7rYzh
xqhgHhrv5e74RIwzPLuC/NO2bnMC9k0CpSjGJCvFovcsROE4COjpLlaXS6XzHEOt
QHT3d9uDcgSM/VCARFM5t9w7tMKXgvRYiR8ydWVaF2AS8wk3Y8k0JA+CQFZrurWy
e14SOTYt2872qlWIFQazSRgJ3gtiuGsfHurEyQJtidie6oVZ/DVwtB3M8YFHKzIl
nRPn9lSc8Uijdumkdss+MPY1ZayhG1HSRig3/kLWoEyNYcdnpV8=
=moDc
-----END PGP SIGNATURE-----
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.