From 2b01dfaa17eaffd9854e505eb6f63155e5e5a82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Wed, 26 Sep 2018 15:09:59 +0200 Subject: [PATCH] Close the DB before deleting ooni_home --- internal/cli/reset/reset.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/cli/reset/reset.go b/internal/cli/reset/reset.go index bc7562e..85ceba2 100644 --- a/internal/cli/reset/reset.go +++ b/internal/cli/reset/reset.go @@ -15,7 +15,14 @@ func init() { cmd.Action(func(_ *kingpin.ParseContext) error { ctx, err := root.Init() if err != nil { - log.Errorf("%s", err) + log.WithError(err).Error("failed to init root context") + return err + } + // We need to first the DB otherwise the DB will be rewritten on close when + // we delete the home directory. + err = ctx.DB.Close() + if err != nil { + log.WithError(err).Error("failed to close the DB") return err } if *force == true {