all repos — honk @ 069224ad431d5d7a9210bd7bf1893dac9b2eda69

my fork of honk

clean up blob if init fails. from timkuijsten
Ted Unangst tedu@tedunangst.com
Sun, 24 Sep 2023 22:14:50 -0400
commit

069224ad431d5d7a9210bd7bf1893dac9b2eda69

parent

87d4da63d22d730c0d010a3f15173a43de0dfce5

1 files changed, 5 insertions(+), 3 deletions(-)

jump to
M util.goutil.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)