Document that we use WAL + run a checkpoint after hishtory imports

This commit is contained in:
David Dworken 2022-11-11 17:14:11 -05:00
parent 9c47afbe54
commit 42e0ac2195
No known key found for this signature in database
3 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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))