clean up blob if init fails. from timkuijsten
Ted Unangst tedu@tedunangst.com
Sun, 24 Sep 2023 22:14:50 -0400
1 files changed,
5 insertions(+),
3 deletions(-)
jump to
M
util.go
→
util.go
@@ -58,6 +58,7 @@ var alreadyopendb *sql.DB
var stmtConfig *sql.Stmt func initdb() { + blobdbname := dataDir + "/blob.db" dbname := dataDir + "/honk.db" _, err := os.Stat(dbname) if err == nil {@@ -70,6 +71,7 @@ }
alreadyopendb = db defer func() { os.Remove(dbname) + os.Remove(blobdbname) os.Exit(1) }() c := make(chan os.Signal, 1)@@ -79,6 +81,7 @@ <-c
C.termecho(1) fmt.Printf("\n") os.Remove(dbname) + os.Remove(blobdbname) os.Exit(1) }()@@ -96,7 +99,7 @@ }
} r := bufio.NewReader(os.Stdin) - initblobdb() + initblobdb(blobdbname) prepareStatements(db)@@ -152,8 +155,7 @@ fmt.Printf("done.\n")
os.Exit(0) } -func initblobdb() { - blobdbname := dataDir + "/blob.db" +func initblobdb(blobdbname string) { _, err := os.Stat(blobdbname) if err == nil { elog.Fatalf("%s already exists", blobdbname)