aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/forward.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-10-23 21:27:09 +0200
committerRobin Jarry <robin@jarry.cc>2022-11-09 21:14:33 +0100
commitf479ae8c6e550dade0f183da9d3d7760f406d806 (patch)
tree6e956d10ee77d9cca6b943677af9d5b7161e0560 /commands/msg/forward.go
parent3e52278e86d07192a21a2624ccbabdc1d3ea5ad6 (diff)
downloadaerc-f479ae8c6e550dade0f183da9d3d7760f406d806.tar.gz
lib: prepare attachments for multiple reads
Prepare attachments for multiple reads. The data for lib.PartAttachment is stored as an io.Reader which can only be read once. This will cause an issue when we want to call composer.WriteMessage multiple times, i.e. for a message preview. We fix this by keeping a copy of the data and create a new reader everytime the attachment is read. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/msg/forward.go')
-rw-r--r--commands/msg/forward.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index 78c24380..ccfaa086 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -205,8 +205,12 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
name = fmt.Sprintf("%s_%s_%d", bs.MIMEType, bs.MIMESubType, rand.Uint64())
}
mu.Lock()
- composer.AddPartAttachment(name, mime, params, reader)
+ err := composer.AddPartAttachment(name, mime, params, reader)
mu.Unlock()
+ if err != nil {
+ logging.Errorf(err.Error())
+ aerc.PushError(err.Error())
+ }
})
}
}