From b0e92f6d474ce91d7f071f9ed62bbb2015009c58 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 9 Jun 2008 13:52:45 +0000 Subject: * Merged the no-bdb branch (-r10900:HEAD https://svn.nixos.org/repos/nix/nix/branches/no-bdb). --- src/nix-store/nix-store.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/nix-store/nix-store.cc') 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(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(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); } -- cgit 1.4.1