Skip to content

Commit 1e7c796

Browse files
authored
Merge pull request NixOS#5475 from doronbehar/SQLiteWAL-vfs
libstore: Use unix-dotfile vfs if useSQLiteWAL is false
2 parents ae14113 + 14fcf17 commit 1e7c796

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libstore/sqlite.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "sqlite.hh"
2+
#include "globals.hh"
23
#include "util.hh"
34

45
#include <sqlite3.h>
@@ -27,8 +28,12 @@ namespace nix {
2728

2829
SQLite::SQLite(const Path & path, bool create)
2930
{
31+
// useSQLiteWAL also indicates what virtual file system we need. Using
32+
// `unix-dotfile` is needed on NFS file systems and on Windows' Subsystem
33+
// for Linux (WSL) where useSQLiteWAL should be false by default.
34+
const char *vfs = settings.useSQLiteWAL ? 0 : "unix-dotfile";
3035
if (sqlite3_open_v2(path.c_str(), &db,
31-
SQLITE_OPEN_READWRITE | (create ? SQLITE_OPEN_CREATE : 0), 0) != SQLITE_OK)
36+
SQLITE_OPEN_READWRITE | (create ? SQLITE_OPEN_CREATE : 0), vfs) != SQLITE_OK)
3237
throw Error("cannot open SQLite database '%s'", path);
3338

3439
if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK)

0 commit comments

Comments
 (0)