~migadu/alps-devel

alps: smtp: fix calling Close() twice v1 SUPERSEDED

~koukas: 1
 smtp: fix calling Close() twice

 1 files changed, 0 insertions(+), 4 deletions(-)
#864920 .build.yml success
DotWriter adds the final .\r\n line when closed.
This happens twice if the first Close() doesn't fail.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~migadu/alps-devel/patches/36198/mbox | git am -3
Learn more about email & git

[PATCH alps] smtp: fix calling Close() twice Export this patch

From: Konstantinos Koukas <contact@koukas.org>

---
 plugins/base/smtp.go | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/plugins/base/smtp.go b/plugins/base/smtp.go
index 1809059..f406647 100644
--- a/plugins/base/smtp.go
+++ b/plugins/base/smtp.go
@@ -100,13 +100,11 @@ func writeAttachment(mw *mail.Writer, att Attachment) error {
	if err != nil {
		return fmt.Errorf("failed to create attachment: %v", err)
	}
	defer aw.Close()

	f, err := att.Open()
	if err != nil {
		return fmt.Errorf("failed to open attachment: %v", err)
	}
	defer f.Close()

	if _, err := io.Copy(aw, f); err != nil {
		return fmt.Errorf("failed to write attachment: %v", err)
@@ -166,7 +164,6 @@ func (msg *OutgoingMessage) WriteTo(w io.Writer) error {
	if err != nil {
		return fmt.Errorf("failed to create text part: %v", err)
	}
	defer tw.Close()

	if _, err := io.WriteString(tw, msg.Text); err != nil {
		return fmt.Errorf("failed to write text part: %v", err)
@@ -206,7 +203,6 @@ func sendMessage(c *smtp.Client, msg *OutgoingMessage) error {
	if err != nil {
		return fmt.Errorf("DATA failed: %v", err)
	}
	defer w.Close()

	if err := msg.WriteTo(w); err != nil {
		return fmt.Errorf("failed to write outgoing message: %v", err)
-- 
2.34.4
alps/patches/.build.yml: SUCCESS in 59s

[smtp: fix calling Close() twice][0] from [~koukas][1]

[0]: https://lists.sr.ht/~migadu/alps-devel/patches/36198
[1]: mailto:contact@koukas.org

✓ #864920 SUCCESS alps/patches/.build.yml https://builds.sr.ht/~migadu/job/864920
These are intentional, to ensure we call Close on error.