1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-19 08:49:35 +01:00

Rename ReadOnly to Immutable and clarify its purpose.

This commit is contained in:
Ben Radford 2023-05-16 15:48:40 +01:00
parent aa376f4ab1
commit b1a7b26eef
No known key found for this signature in database
GPG key ID: 9DF5D4640AB888D5
3 changed files with 9 additions and 7 deletions

View file

@ -53,15 +53,14 @@ static void traceSQL(void * x, const char * sql)
SQLite::SQLite(const Path & path, SQLiteOpenMode mode)
{
bool readOnly = mode == SQLiteOpenMode::ReadOnly;
// useSQLiteWAL also indicates what virtual file system we need. Using
// `unix-dotfile` is needed on NFS file systems and on Windows' Subsystem
// for Linux (WSL) where useSQLiteWAL should be false by default.
const char *vfs = settings.useSQLiteWAL ? 0 : "unix-dotfile";
int flags = readOnly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE;
bool immutable = mode == SQLiteOpenMode::Immutable;
int flags = immutable ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE;
if (mode == SQLiteOpenMode::Normal) flags |= SQLITE_OPEN_CREATE;
auto uri = "file:" + percentEncode(path) + "?immutable=" + (readOnly ? "1" : "0");
auto uri = "file:" + percentEncode(path) + "?immutable=" + (immutable ? "1" : "0");
int ret = sqlite3_open_v2(uri.c_str(), &db, SQLITE_OPEN_URI | flags, vfs);
if (ret != SQLITE_OK) {
const char * err = sqlite3_errstr(ret);