aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/nar-info-disk-cache.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-08-09 14:27:30 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-08-10 18:05:35 +0200
commitf294623d1d2d42cd6671c061d3e146b05b930afb (patch)
tree9217e9bb453beb37b8bf3d4610e47e7e9fa5b211 /src/libstore/nar-info-disk-cache.cc
parent6cb4bdf1526bacb02fec015f89267e519b654b84 (diff)
SQLite:: Add some convenience
Diffstat (limited to 'src/libstore/nar-info-disk-cache.cc')
-rw-r--r--src/libstore/nar-info-disk-cache.cc13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index 172a918ff..d28ff42c7 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -78,21 +78,16 @@ public:
Path dbPath = getCacheDir() + "/nix/binary-cache-v5.sqlite";
createDirs(dirOf(dbPath));
- if (sqlite3_open_v2(dbPath.c_str(), &state->db.db,
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0) != SQLITE_OK)
- throw Error(format("cannot open store cache ā€˜%sā€™") % dbPath);
+ state->db = SQLite(dbPath);
if (sqlite3_busy_timeout(state->db, 60 * 60 * 1000) != SQLITE_OK)
throwSQLiteError(state->db, "setting timeout");
// We can always reproduce the cache.
- if (sqlite3_exec(state->db, "pragma synchronous = off", 0, 0, 0) != SQLITE_OK)
- throwSQLiteError(state->db, "making database asynchronous");
- if (sqlite3_exec(state->db, "pragma main.journal_mode = truncate", 0, 0, 0) != SQLITE_OK)
- throwSQLiteError(state->db, "setting journal mode");
+ state->db.exec("pragma synchronous = off");
+ state->db.exec("pragma main.journal_mode = truncate");
- if (sqlite3_exec(state->db, schema, 0, 0, 0) != SQLITE_OK)
- throwSQLiteError(state->db, "initialising database schema");
+ state->db.exec(schema);
state->insertCache.create(state->db,
"insert or replace into BinaryCaches(url, timestamp, storeDir, wantMassQuery, priority) values (?, ?, ?, ?, ?)");