diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 9d3cea7a0..ea1770fc5 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -49,8 +49,7 @@ LocalStore::LocalStore() checkStoreNotSymlink(); Path globalLockPath = nixDBPath + "/big-lock"; - globalLock = open(globalLockPath.c_str(), O_RDWR | O_CREAT, 0666); - if (globalLock == -1) throw SysError(format("opening file `%1%'") % globalLockPath); + globalLock = openLockFile(globalLockPath.c_str(), true); if (!lockFile(globalLock, ltRead, false)) { printMsg(lvlError, "waiting for the big Nix store lock..."); diff --git a/src/libstore/upgrade-schema.cc b/src/libstore/upgrade-schema.cc index d54e29bd9..450a7c8d0 100644 --- a/src/libstore/upgrade-schema.cc +++ b/src/libstore/upgrade-schema.cc @@ -22,6 +22,11 @@ void LocalStore::upgradeStore12() { #if OLD_DB_COMPAT +#ifdef __CYGWIN__ + /* Cygwin can't upgrade a read lock to a write lock... */ + lockFile(globalLock, ltNone, true); +#endif + if (!lockFile(globalLock, ltWrite, false)) { printMsg(lvlError, "waiting for exclusive access to the Nix store..."); lockFile(globalLock, ltWrite, true);