Use sqlite3_file_control(SQLITE_FCNTL_PERSIST_WAL) to persist WAL

Previously, Litestream would avoid closing the SQLite3 connection
in order to ensure that the WAL file was not cleaned up by the
database if it was the last connection. This commit changes the
behavior by introducing a file control call to perform the same
action. This allows us to close the database file normally in all
cases.
This commit is contained in:
Ben Johnson
2022-01-28 15:05:21 -07:00
parent 1741c82839
commit dbdde21341
6 changed files with 27 additions and 24 deletions

View File

@@ -254,8 +254,8 @@ func TestDB_Sync(t *testing.T) {
t.Fatal(err)
}
// Verify WAL does not exist.
if _, err := os.Stat(db.WALPath()); !os.IsNotExist(err) {
// Remove WAL file.
if err := os.Remove(db.WALPath()); err != nil {
t.Fatal(err)
}