From 42e0ac21956aaac48f239799ab44ee498416e3a8 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Fri, 11 Nov 2022 17:14:11 -0500 Subject: [PATCH] Document that we use WAL + run a checkpoint after hishtory imports --- README.md | 2 +- client/lib/lib.go | 2 ++ hishtory.go | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0d59218..776ea68 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Both support the same query format, see the below annotated queries: | `service before:2022-02-01` | Find all commands containing `service` run before February 1st 2022 | | `service after:2022-02-01` | Find all commands containing `service` run after February 1st 2022 | -For true power users, you can even query in SQLite via `sqlite3 ~/.hishtory/.hishtory.db`. +For true power users, you can even query in SQLite via `sqlite3 -cmd 'PRAGMA journal_mode = WAL' ~/.hishtory/.hishtory.db`. ### Enable/Disable diff --git a/client/lib/lib.go b/client/lib/lib.go index 97cbd06..25d622f 100644 --- a/client/lib/lib.go +++ b/client/lib/lib.go @@ -584,6 +584,8 @@ func ImportHistory(ctx *context.Context, shouldReadStdin bool) (int, error) { if err != nil { return 0, fmt.Errorf("failed to mark initial import as completed, this may lead to duplicate history entries: %v", err) } + // Trigger a checkpoint so that these bulk entries are added from the WAL to the main DB + db.Exec("PRAGMA wal_checkpoint") return len(historyEntries), nil } diff --git a/hishtory.go b/hishtory.go index 0d1dca2..318160b 100644 --- a/hishtory.go +++ b/hishtory.go @@ -112,7 +112,6 @@ func main() { if numImported > 0 { fmt.Printf("Imported %v history entries from your existing shell history\n", numImported) } - // TODO: maybe trigger a checkpoint? I suspect that is the root cause of #24 case "enable": ctx := hctx.MakeContext() lib.CheckFatalError(lib.Enable(ctx))