Do not check for write access to database when read-only.

This commit is contained in:
Ben Radford 2023-05-16 13:57:13 +01:00
parent c22936ca6a
commit 7f443e0428
No known key found for this signature in database
GPG key ID: 9DF5D4640AB888D5

View file

@ -480,7 +480,7 @@ int LocalStore::getSchema()
void LocalStore::openDB(State & state, bool create)
{
if (access(dbDir.c_str(), R_OK | W_OK))
if (access(dbDir.c_str(), R_OK | (readOnly ? 0 : W_OK)))
throw SysError("Nix database directory '%1%' is not writable", dbDir);
/* Open the Nix database. */