From 4d2b02e2c3a2cef14a408bc9744ba8ff0d256ac2 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 19 Nov 2023 08:52:27 -0800 Subject: [PATCH] Add error checking when clearing the DB during the init process --- client/cmd/install.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/cmd/install.go b/client/cmd/install.go index e0a3f01..7fe803b 100644 --- a/client/cmd/install.go +++ b/client/cmd/install.go @@ -579,7 +579,10 @@ func setup(userSecret string, isOffline bool) error { if err != nil { return err } - db.Exec("DELETE FROM history_entries") + err = db.Exec("DELETE FROM history_entries").Error + if err != nil { + return fmt.Errorf("failed to reset local DB during setup: %w", err) + } // Bootstrap from remote date if config.IsOffline { @@ -604,6 +607,7 @@ func setup(userSecret string, isOffline bool) error { if err != nil { return fmt.Errorf("failed to load JSON response: %w", err) } + hctx.GetLogger().Infof("Bootstrapping new device: Found %d entries", len(retrievedEntries)) for _, entry := range retrievedEntries { decEntry, err := data.DecryptHistoryEntry(userSecret, *entry) if err != nil {