about summary refs log tree commit diff
path: root/src/nix-store/nix-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-06-09T13·52+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-06-09T13·52+0000
commitb0e92f6d474ce91d7f071f9ed62bbb2015009c58 (patch)
treec3d28be6b89dfa618df290d5c78c55897b119b6c /src/nix-store/nix-store.cc
parent4ed01ed791b3bb7a4010049c6128aa2d49a81a29 (diff)
* Merged the no-bdb branch (-r10900:HEAD
  https://svn.nixos.org/repos/nix/nix/branches/no-bdb).

Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r--src/nix-store/nix-store.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 17b3c18fad9f..df027fcc7646 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -7,7 +7,6 @@
 #include "shared.hh"
 #include "dotgraph.hh"
 #include "local-store.hh"
-#include "db.hh"
 #include "util.hh"
 #include "help.txt.hh"
 
@@ -31,6 +30,14 @@ static int rootNr = 0;
 static bool indirectRoot = false;
 
 
+LocalStore & ensureLocalStore()
+{
+    LocalStore * store2(dynamic_cast<LocalStore *>(store.get()));
+    if (!store2) throw Error("you don't have sufficient rights to use --verify");
+    return *store2;
+}
+
+
 static Path useDeriver(Path path)
 {       
     if (!isDerivation(path)) {
@@ -430,10 +437,7 @@ static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
         }
     }
 
-    Transaction txn;
-    createStoreTransaction(txn);
-    registerValidPaths(txn, infos);
-    txn.commit();
+    ensureLocalStore().registerValidPaths(infos);
 }
 
 
@@ -641,11 +645,10 @@ static void opVerify(Strings opFlags, Strings opArgs)
         if (*i == "--check-contents") checkContents = true;
         else throw UsageError(format("unknown flag `%1%'") % *i);
     
-    verifyStore(checkContents);
+    ensureLocalStore().verifyStore(checkContents);
 }
 
 
-
 static void showOptimiseStats(OptimiseStats & stats)
 {
     printMsg(lvlError,
@@ -671,12 +674,9 @@ static void opOptimise(Strings opFlags, Strings opArgs)
         if (*i == "--dry-run") dryRun = true;
         else throw UsageError(format("unknown flag `%1%'") % *i);
 
-    LocalStore * store2(dynamic_cast<LocalStore *>(store.get()));
-    if (!store2) throw Error("you don't have sufficient rights to use --optimise");
-
     OptimiseStats stats;
     try {
-        store2->optimiseStore(dryRun, stats);
+        ensureLocalStore().optimiseStore(dryRun, stats);
     } catch (...) {
         showOptimiseStats(stats);
         throw;
@@ -755,7 +755,7 @@ void run(Strings args)
     if (!op) throw UsageError("no operation specified");
 
     if (op != opDump && op != opRestore) /* !!! hack */
-        store = openStore(op != opGC);
+        store = openStore();
 
     op(opFlags, opArgs);
 }