2
0
mirror of https://github.com/carlostrub/sisyphus synced 2024-10-31 09:20:15 +00:00

Store sisyphus.db in Maildir

This commit is contained in:
Carlo Strub 2017-03-12 22:50:43 +00:00
parent 754eac57b1
commit 3bc9beb113
2 changed files with 4 additions and 13 deletions

View File

@ -5,11 +5,11 @@ import (
)
// openDB creates and opens a new database and its respective buckets (if required)
func openDB(path string) (db *bolt.DB, err error) {
func openDB(maildir string) (db *bolt.DB, err error) {
// Open the sisyphus.db data file in your current directory.
// It will be created if it doesn't exist.
db, err = bolt.Open(path, 0600, nil)
db, err = bolt.Open(maildir+"/sisyphus.db", 0600, nil)
if err != nil {
return db, err
}

13
main.go
View File

@ -20,7 +20,7 @@ func main() {
panic(err)
}
var maildir, database *string
var maildir *string
// Define App
app := cli.NewApp()
@ -46,12 +46,6 @@ func main() {
Usage: "Path to the Maildir directory",
Destination: maildir,
},
cli.StringFlag{
Name: "database",
Value: wd + "/sisyphus.db",
Usage: "Path to the sisyphus database",
Destination: database,
},
}
app.Commands = []cli.Command{
@ -60,9 +54,6 @@ func main() {
Aliases: []string{"s"},
Usage: "start sisyphus daemon",
Action: func(c *cli.Context) error {
if database == nil {
return errors.New("no database selected")
}
if maildir == nil {
return errors.New("no maildir selected")
}
@ -76,7 +67,7 @@ func main() {
fmt.Println(mails)
// Open the database
db, err := openDB(*database)
db, err := openDB(*maildir)
if err != nil {
return cli.NewExitError(err, 66)
}