diff options
author | Reto Brunner <reto@labrat.space> | 2020-05-17 11:44:38 +0200 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-05-17 11:44:38 +0200 |
commit | 13a6a3fa7109ce6dcff79ea9ed2a012226386fad (patch) | |
tree | f182c5d8f8dbaf5a6445b5c226a229faa7005efa /commands/msgview | |
parent | bae678e8f20605b64596c9e976623f2a37247adb (diff) | |
download | aerc-13a6a3fa7109ce6dcff79ea9ed2a012226386fad.tar.gz |
FetchBodyPart doesn't need the parent body structure
Diffstat (limited to 'commands/msgview')
-rw-r--r-- | commands/msgview/open.go | 2 | ||||
-rw-r--r-- | commands/msgview/save.go | 29 |
2 files changed, 15 insertions, 16 deletions
diff --git a/commands/msgview/open.go b/commands/msgview/open.go index 44584f9..f708b2d 100644 --- a/commands/msgview/open.go +++ b/commands/msgview/open.go @@ -36,7 +36,7 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error { p := mv.SelectedMessagePart() store := mv.Store() - store.FetchBodyPart(p.Msg.Uid, p.Msg.BodyStructure, p.Index, func(reader io.Reader) { + store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) { extension := "" // try to determine the correct extension based on mimetype if part, err := p.Msg.BodyStructure.PartAtIndex(p.Index); err == nil { diff --git a/commands/msgview/save.go b/commands/msgview/save.go index f3cbb70..ef6bba8 100644 --- a/commands/msgview/save.go +++ b/commands/msgview/save.go @@ -109,21 +109,20 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error { ch := make(chan error, 1) store := mv.Store() - store.FetchBodyPart( - pi.Msg.Uid, pi.Msg.BodyStructure, pi.Index, func(reader io.Reader) { - f, err := os.Create(path) - if err != nil { - ch <- err - return - } - defer f.Close() - _, err = io.Copy(f, reader) - if err != nil { - ch <- err - return - } - ch <- nil - }) + store.FetchBodyPart(pi.Msg.Uid, pi.Index, func(reader io.Reader) { + f, err := os.Create(path) + if err != nil { + ch <- err + return + } + defer f.Close() + _, err = io.Copy(f, reader) + if err != nil { + ch <- err + return + } + ch <- nil + }) // we need to wait for the callback prior to displaying a result go func() { |