about summary refs log tree commit diff
path: root/src/nix-env
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-14T22·33+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-14T22·33+0000
commit86cbd93ec1e439fba3e33016272db45d9597fba4 (patch)
treefba307cb8e657a23ee1082ce38507d431dca30f8 /src/nix-env
parent5c38c863bdb6904f28a929b97e91d283e29aea70 (diff)
* nix-env --switch-generation / --list-generations /
  --delete-generations: lock the profile to prevent (extremely
  unlikely) race conditions.

Diffstat (limited to 'src/nix-env')
-rw-r--r--src/nix-env/main.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc
index 7a6824b63acf..416f89bcc16d 100644
--- a/src/nix-env/main.cc
+++ b/src/nix-env/main.cc
@@ -943,6 +943,9 @@ static const int prevGen = -2;
 
 static void switchGeneration(Globals & globals, int dstGen)
 {
+    PathLocks lock;
+    lockProfile(lock, globals.profile);
+    
     int curGen;
     Generations gens = findGenerations(globals.profile, curGen);
 
@@ -1004,6 +1007,9 @@ static void opListGenerations(Globals & globals,
     if (opArgs.size() != 0)
         throw UsageError(format("no arguments expected"));
 
+    PathLocks lock;
+    lockProfile(lock, globals.profile);
+    
     int curGen;
     Generations gens = findGenerations(globals.profile, curGen);
 
@@ -1032,6 +1038,9 @@ static void opDeleteGenerations(Globals & globals,
     if (opFlags.size() > 0)
         throw UsageError(format("unknown flag `%1%'") % opFlags.front());
 
+    PathLocks lock;
+    lockProfile(lock, globals.profile);
+    
     int curGen;
     Generations gens = findGenerations(globals.profile, curGen);