diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc index 8faa73028..292d76e02 100644 --- a/src/libexpr/eval-cache.cc +++ b/src/libexpr/eval-cache.cc @@ -70,10 +70,10 @@ struct AttrDb { auto state(_state->lock()); - Path cacheDir = getCacheDir() + "/eval-cache-v5"; + auto cacheDir = std::filesystem::path(getCacheDir()) / "eval-cache-v6"; createDirs(cacheDir); - Path dbPath = cacheDir + "/" + fingerprint.to_string(HashFormat::Base16, false) + ".sqlite"; + auto dbPath = cacheDir / (fingerprint.to_string(HashFormat::Base16, false) + ".sqlite"); state->db = SQLite(dbPath); state->db.isCache(); diff --git a/src/libfetchers/cache.cc b/src/libfetchers/cache.cc index ed4776704..67361c765 100644 --- a/src/libfetchers/cache.cc +++ b/src/libfetchers/cache.cc @@ -38,7 +38,7 @@ struct CacheImpl : Cache { auto state(_state.lock()); - auto dbPath = getCacheDir() + "/fetcher-cache-v3.sqlite"; + auto dbPath = getCacheDir() + "/fetcher-cache-v4.sqlite"; createDirs(dirOf(dbPath)); state->db = SQLite(dbPath); diff --git a/src/libstore/include/nix/store/sqlite.hh b/src/libstore/include/nix/store/sqlite.hh index e6d8a818a..3495c0bd1 100644 --- a/src/libstore/include/nix/store/sqlite.hh +++ b/src/libstore/include/nix/store/sqlite.hh @@ -1,6 +1,7 @@ #pragma once ///@file +#include #include #include @@ -41,7 +42,7 @@ struct SQLite SQLite() {} - SQLite(const Path & path, SQLiteOpenMode mode = SQLiteOpenMode::Normal); + SQLite(const std::filesystem::path & path, SQLiteOpenMode mode = SQLiteOpenMode::Normal); SQLite(const SQLite & from) = delete; SQLite & operator=(const SQLite & from) = delete; diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 55862477c..a66a97866 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -488,12 +488,11 @@ void LocalStore::openDB(State & state, bool create) throw SysError("Nix database directory '%1%' is not writable", dbDir); /* Open the Nix database. */ - std::string dbPath = dbDir + "/db.sqlite"; auto & db(state.db); auto openMode = config->readOnly ? SQLiteOpenMode::Immutable : create ? SQLiteOpenMode::Normal : SQLiteOpenMode::NoCreate; - state.db = SQLite(dbPath, openMode); + state.db = SQLite(std::filesystem::path(dbDir) / "db.sqlite", openMode); #ifdef __CYGWIN__ /* The cygwin version of sqlite3 has a patch which calls diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc index 0350c874a..69d8d2e14 100644 --- a/src/libstore/nar-info-disk-cache.cc +++ b/src/libstore/nar-info-disk-cache.cc @@ -86,7 +86,7 @@ public: Sync _state; - NarInfoDiskCacheImpl(Path dbPath = getCacheDir() + "/binary-cache-v6.sqlite") + NarInfoDiskCacheImpl(Path dbPath = getCacheDir() + "/binary-cache-v7.sqlite") { auto state(_state.lock()); diff --git a/src/libstore/sqlite.cc b/src/libstore/sqlite.cc index dd9f10422..56a69470a 100644 --- a/src/libstore/sqlite.cc +++ b/src/libstore/sqlite.cc @@ -58,7 +58,7 @@ static void traceSQL(void * x, const char * sql) notice("SQL<[%1%]>", sql); }; -SQLite::SQLite(const Path & path, SQLiteOpenMode mode) +SQLite::SQLite(const std::filesystem::path & path, SQLiteOpenMode mode) { // useSQLiteWAL also indicates what virtual file system we need. Using // `unix-dotfile` is needed on NFS file systems and on Windows' Subsystem @@ -68,7 +68,7 @@ SQLite::SQLite(const Path & path, SQLiteOpenMode mode) int flags = immutable ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE; if (mode == SQLiteOpenMode::Normal) flags |= SQLITE_OPEN_CREATE; - auto uri = "file:" + percentEncode(path) + "?immutable=" + (immutable ? "1" : "0"); + auto uri = "file:" + percentEncode(path.string()) + "?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); @@ -99,7 +99,7 @@ SQLite::~SQLite() void SQLite::isCache() { exec("pragma synchronous = off"); - exec("pragma main.journal_mode = truncate"); + exec("pragma main.journal_mode = wal"); } void SQLite::exec(const std::string & stmt)