mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Merge pull request #7497 from rski/master
src/libstore: Print the reason opening the DB failed
This commit is contained in:
commit
ae31b5f50f
1 changed files with 7 additions and 3 deletions
|
@ -47,9 +47,13 @@ SQLite::SQLite(const Path & path, bool create)
|
||||||
// `unix-dotfile` is needed on NFS file systems and on Windows' Subsystem
|
// `unix-dotfile` is needed on NFS file systems and on Windows' Subsystem
|
||||||
// for Linux (WSL) where useSQLiteWAL should be false by default.
|
// for Linux (WSL) where useSQLiteWAL should be false by default.
|
||||||
const char *vfs = settings.useSQLiteWAL ? 0 : "unix-dotfile";
|
const char *vfs = settings.useSQLiteWAL ? 0 : "unix-dotfile";
|
||||||
if (sqlite3_open_v2(path.c_str(), &db,
|
int flags = SQLITE_OPEN_READWRITE;
|
||||||
SQLITE_OPEN_READWRITE | (create ? SQLITE_OPEN_CREATE : 0), vfs) != SQLITE_OK)
|
if (create) flags |= SQLITE_OPEN_CREATE;
|
||||||
throw Error("cannot open SQLite database '%s'", path);
|
int ret = sqlite3_open_v2(path.c_str(), &db, flags, vfs);
|
||||||
|
if (ret != SQLITE_OK) {
|
||||||
|
const char * err = sqlite3_errstr(ret);
|
||||||
|
throw Error("cannot open SQLite database '%s': %s", path, err);
|
||||||
|
}
|
||||||
|
|
||||||
if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK)
|
if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK)
|
||||||
SQLiteError::throw_(db, "setting timeout");
|
SQLiteError::throw_(db, "setting timeout");
|
||||||
|
|
Loading…
Reference in a new issue