diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-01-31T09·19+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-01-31T09·28+0100 |
commit | 9e7c1a4bbdbe6129dd9dc385776612c307d3d1bb (patch) | |
tree | 4c213493e9c6fa1045df1b4192061602e31c78eb /src/libstore/local-store.cc | |
parent | 4fa08f3edb413e65816441acfb6c3befee730a06 (diff) |
Use the daemon when we don't have write access to the Nix database
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r-- | src/libstore/local-store.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 9199b12063a0..55bd3e70e7b8 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -397,9 +397,15 @@ int LocalStore::getSchema() } +bool LocalStore::haveWriteAccess() +{ + return access(settings.nixDBPath.c_str(), R_OK | W_OK) == 0; +} + + void LocalStore::openDB(bool create) { - if (access(settings.nixDBPath.c_str(), R_OK | W_OK)) + if (!haveWriteAccess()) throw SysError(format("Nix database directory ‘%1%’ is not writable") % settings.nixDBPath); /* Open the Nix database. */ |