New utility to import mail into PostgreSQL.

Minor leak cleanup in mailhash.
This commit is contained in:
2014-03-18 23:01:15 -07:00
parent f7c0774798
commit bb8f546fd0
3 changed files with 165 additions and 2 deletions

View File

@@ -7,7 +7,6 @@ import (
"os"
"path/filepath"
"strings"
"xinu.tv/email"
"github.com/golang/glog"
@@ -47,14 +46,22 @@ func (m *Messages) hashMail(path string, info os.FileInfo, err error) error {
return nil
}
base := filepath.Base(path)
if _, ok := m.Skip[base]; ok {
glog.Infoln("Skipping", path)
return nil
}
r, err := os.Open(path)
if err != nil {
glog.Fatal(err)
}
defer r.Close()
h, err := email.Hash(r, headers)
if err != nil {
glog.Errorf("%s not an mail file", path)
glog.Info("%q", err.Error())
glog.Infof("%q", err.Error())
return nil
}
md := email.NewInfo(path)
@@ -130,6 +137,7 @@ func (m Messages) Reconcile(maildir string) error {
if err != nil {
glog.Fatal(err)
}
defer r.Close()
h, err := email.Hash(r, headers)
if err != nil {