about summary refs log tree commit diff
path: root/src/nix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-01T15·41+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-01T15·41+0000
commitc95b4ad2906ce4076f04e0969b7080c0589a8cea (patch)
treece3d6690834645117d2d6dfa714161fe97e09ca6 /src/nix.cc
parentd99d04e6442dcc39a24cebac01af117ce00a5006 (diff)
* In normaliseFState(), wrap registration of the output paths and the
  normal form in a single transaction to ensure that if we crash,
  either everything is registered or nothing is.  This is for
  recoverability: unregistered paths in the store can be deleted
  arbitrarily, while registered paths can only be deleted by running
  the garbage collector.

Diffstat (limited to 'src/nix.cc')
-rw-r--r--src/nix.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nix.cc b/src/nix.cc
index 42cc4a87c228..4beeb5da8943 100644
--- a/src/nix.cc
+++ b/src/nix.cc
@@ -239,14 +239,16 @@ static void opSuccessor(Strings opFlags, Strings opArgs)
 {
     if (!opFlags.empty()) throw UsageError("unknown flag");
     if (opArgs.size() % 2) throw UsageError("expecting even number of arguments");
-    
+
+    Transaction txn(nixDB); /* !!! this could be a big transaction */ 
     for (Strings::iterator i = opArgs.begin();
          i != opArgs.end(); )
     {
         FSId id1 = parseHash(*i++);
         FSId id2 = parseHash(*i++);
-        registerSuccessor(id1, id2);
+        registerSuccessor(txn, id1, id2);
     }
+    txn.commit();
 }