From c95b4ad2906ce4076f04e0969b7080c0589a8cea Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 1 Aug 2003 15:41:47 +0000 Subject: * 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. --- src/nix.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nix.cc') 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(); } -- cgit 1.4.1