From 59df06fe28ddde3607cb3080636e65d48b762baf Mon Sep 17 00:00:00 2001 From: Stefan Rakel Date: Thu, 27 Jun 2019 11:06:50 +0200 Subject: Reopening mailcontent file to fix #166 Because editors like vim use backupfiles and rename them to the original name, the file handle used can point to the wrong file. Reopening the file should fix this. --- widgets/compose.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'widgets') diff --git a/widgets/compose.go b/widgets/compose.go index 8fc34b4..dc12e60 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -278,7 +278,13 @@ func (c *Composer) PrepareHeader() (*mail.Header, []string, error) { } func (c *Composer) WriteMessage(header *mail.Header, writer io.Writer) error { - c.email.Seek(0, os.SEEK_SET) + name := c.email.Name() + c.email.Close() + file, err := os.Open(name) + if err != nil { + return errors.Wrap(err, "FileOpen") + } + c.email = file var body io.Reader reader, err := mail.CreateReader(c.email) if err == nil { -- cgit v1.2.3