1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-27 12:41:00 +01:00

* Lock the Nix store during upgrades.

This commit is contained in:
Eelco Dolstra 2008-03-08 23:47:05 +00:00
parent 4df6dc28c3
commit 341b2de643
5 changed files with 53 additions and 26 deletions

View file

@ -3,6 +3,7 @@
#include "util.hh"
#include "local-store.hh"
#include "globals.hh"
#include "pathlocks.hh"
#include <iostream>
@ -18,8 +19,15 @@ Hash parseHashField(const Path & path, const string & s);
meta-information in files. */
void LocalStore::upgradeStore12()
{
if (!lockFile(globalLock, ltWrite, false)) {
printMsg(lvlError, "waiting for exclusive access to the Nix store...");
lockFile(globalLock, ltWrite, true);
}
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
if (getSchema() >= nixSchemaVersion) return; /* somebody else beat us to it */
/* Open the old Nix database and tables. */
Database nixDB;
nixDB.open(nixDBPath);
@ -76,6 +84,10 @@ void LocalStore::upgradeStore12()
}
std::cerr << std::endl;
writeFile(schemaPath, (format("%1%") % nixSchemaVersion).str());
lockFile(globalLock, ltRead, true);
}