Add dryrun mode to contacts.
This commit is contained in:
parent
4eaa3b8710
commit
27f38e6614
@ -5,17 +5,22 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/mail"
|
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
"xinu.tv/types"
|
"xinu.tv/types"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
|
"xinu.tv/std/net/mail"
|
||||||
)
|
)
|
||||||
|
|
||||||
var all = flag.Bool("all", false,
|
var (
|
||||||
"extract addresses from all messages. Default is to only extract from unprocessed messages.")
|
all = flag.Bool("all", false,
|
||||||
|
"extract addresses from all messages. Default is to only extract from unprocessed messages.")
|
||||||
|
|
||||||
|
dryrun = flag.Bool("dryrun", false, "don't write to the DB.")
|
||||||
|
)
|
||||||
|
|
||||||
type contact struct {
|
type contact struct {
|
||||||
hash string
|
hash string
|
||||||
@ -24,6 +29,12 @@ type contact struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func insertAddresses(db *sql.DB, batch int, contactCh chan *contact, errc chan error) {
|
func insertAddresses(db *sql.DB, batch int, contactCh chan *contact, errc chan error) {
|
||||||
|
if *dryrun {
|
||||||
|
for _ = range contactCh {
|
||||||
|
}
|
||||||
|
errc <- nil
|
||||||
|
return
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
txn *sql.Tx
|
txn *sql.Tx
|
||||||
stmt *sql.Stmt
|
stmt *sql.Stmt
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user