aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Rakel <rakel@embedded.rwth-aachen.de>2019-06-27 11:06:50 +0200
committerDrew DeVault <sir@cmpwn.com>2019-06-27 09:25:27 -0400
commit59df06fe28ddde3607cb3080636e65d48b762baf (patch)
treee043c640ab6943314edc8c2981786303e83516f0
parent963d251289fec0cd4a4e82989b621705c3a8c79d (diff)
downloadaerc-59df06fe28ddde3607cb3080636e65d48b762baf.tar.gz
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.
-rw-r--r--widgets/compose.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index 8fc34b4c..dc12e600 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 {