mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Give a friendly error message if the DB directory is not writable
Previously we would say "error: setting synchronous mode: unable to open database file" which isn't very helpful.
This commit is contained in:
parent
2f9bb5c7e7
commit
d6582c04c1
1 changed files with 6 additions and 2 deletions
|
@ -354,10 +354,14 @@ int LocalStore::getSchema()
|
|||
|
||||
void LocalStore::openDB(bool create)
|
||||
{
|
||||
if (access(settings.nixDBPath.c_str(), R_OK | W_OK))
|
||||
throw SysError(format("Nix database directory `%1%' is not writable") % settings.nixDBPath);
|
||||
|
||||
/* Open the Nix database. */
|
||||
if (sqlite3_open_v2((settings.nixDBPath + "/db.sqlite").c_str(), &db.db,
|
||||
string dbPath = settings.nixDBPath + "/db.sqlite";
|
||||
if (sqlite3_open_v2(dbPath.c_str(), &db.db,
|
||||
SQLITE_OPEN_READWRITE | (create ? SQLITE_OPEN_CREATE : 0), 0) != SQLITE_OK)
|
||||
throw Error("cannot open SQLite database");
|
||||
throw Error(format("cannot open Nix database `%1%'") % dbPath);
|
||||
|
||||
if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK)
|
||||
throwSQLiteError(db, "setting timeout");
|
||||
|
|
Loading…
Reference in a new issue