Browse Source

fasterated

Signed-off-by: Erik Hollensbe <github@hollensbe.org>
main
Erik Hollensbe 3 months ago
parent
commit
f84c6dcfd0
2 changed files with 19 additions and 14 deletions
  1. +1
    -0
      .gitignore
  2. +18
    -14
      sink.go

+ 1
- 0
.gitignore View File

@ -0,0 +1 @@
/Mail

+ 18
- 14
sink.go View File

@ -226,20 +226,24 @@ func run(ctx *cli.Context) error {
for msg := range msgs {
if os.Getenv("SINK_NO_WRITE") == "" {
r := msg.GetBody(&section)
_, w, err := dir.Create(nil)
if err != nil {
listdone <- fmt.Errorf("%q: error creating entry in maildir: %v", name, err)
return
}
if _, err := io.Copy(w, r); err != nil {
listdone <- fmt.Errorf("%q: failure writing mail entry: %v", name, err)
return
}
w.Close()
wg.Add(1)
go func(msg *imap.Message, section *imap.BodySectionName) {
wg.Done()
r := msg.GetBody(section)
_, w, err := dir.Create(nil)
if err != nil {
listdone <- fmt.Errorf("%q: error creating entry in maildir: %v", name, err)
return
}
if _, err := io.Copy(w, r); err != nil {
listdone <- fmt.Errorf("%q: failure writing mail entry: %v", name, err)
return
}
w.Close()
}(msg, &section)
}
messages <- msg


Loading…
Cancel
Save