diff --git a/src/libstore/db.cc b/src/libstore/db.cc index 8b548a0ba..a83e980b8 100644 --- a/src/libstore/db.cc +++ b/src/libstore/db.cc @@ -604,8 +604,8 @@ void Database::setStateRevisions(const Transaction & txn, TableId table, sorted_revisions.push_back(revisions.at(*i)); //Debugging - //for (vector::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i) - // printMsg(lvlError, format("Insert: %1% into %2%") % int2String(revisions.at(*i)) % *i); + for (vector::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i) + printMsg(lvlError, format("Insert: %1% into %2%") % int2String(revisions.at(*i)) % *i); //Convert the int's into Strings Strings data; diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index e35540fc5..c3da4482d 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -594,7 +594,7 @@ void LocalStore::queryAllReferences(const Path & path, PathSet & allReferences, queryAllReferencesTxn(noTxn, path, allReferences, revision); } -void queryReferrers(const Transaction & txn, +void queryReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & referrers, const int revision) { if (!isRealisableComponentOrStatePath(txn, storePath)) @@ -606,11 +606,11 @@ void queryReferrers(const Transaction & txn, void LocalStore::queryReferrers(const Path & storePath, PathSet & referrers, const int revision) { - nix::queryReferrers(noTxn, storePath, referrers, revision); + nix::queryReferrersTxn(noTxn, storePath, referrers, revision); } -void queryStateReferrers(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision) +void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision) { if (!isRealisableComponentOrStatePath(txn, storePath)) throw Error(format("path `%1%' is not valid") % storePath); @@ -620,7 +620,7 @@ void queryStateReferrers(const Transaction & txn, const Path & storePath, PathSe void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers, const int revision) { - nix::queryStateReferrers(noTxn, storePath, stateReferrers, revision); + nix::queryStateReferrersTxn(noTxn, storePath, stateReferrers, revision); } @@ -1623,7 +1623,12 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, */ void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision) { - computeFSClosure(storeOrstatePath, paths, withComponents, withState, revision); + nix::storePathRequisitesTxn(noTxn, storeOrstatePath, includeOutputs, paths, withComponents, withState, revision); +} + +void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision) +{ + computeFSClosureTxn(txn, storeOrstatePath, paths, withComponents, withState, revision); if (includeOutputs) { for (PathSet::iterator i = paths.begin(); @@ -1632,15 +1637,15 @@ void storePathRequisites(const Path & storeOrstatePath, const bool includeOutput Derivation drv = derivationFromPath(*i); for (DerivationOutputs::iterator j = drv.outputs.begin(); j != drv.outputs.end(); ++j) - if (store->isValidPath(j->second.path)) - computeFSClosure(j->second.path, paths, withComponents, withState, revision); + if (isValidPathTxn(txn, j->second.path)) + computeFSClosureTxn(txn, j->second.path, paths, withComponents, withState, revision); } } } void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision) { - return nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision); + nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision); } void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths) diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index eecf8af59..c782a1508 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -225,12 +225,21 @@ bool isStateDrvTxn(const Transaction & txn, const Derivation & drv); //TODO can this ????? void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths); bool isValidStatePathTxn(const Transaction & txn, const Path & path); + void queryReferencesTxn(const Transaction & txn, const Path & path, PathSet & references, const int revision); void queryStateReferencesTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferences, const int revision); + +void queryReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & referrers, const int revision); +void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision); + + Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath); -void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision); +void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision); void setStateRevisionsTxn(const Transaction & txn, const Path & statePath, const RevisionNumbersSet & revisions); +bool isValidPathTxn(const Transaction & txn, const Path & path); +bool isValidStatePathTxn(const Transaction & txn, const Path & path); + } diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 6dd06d628..ca7785b9f 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -1,6 +1,7 @@ #include "misc.hh" #include "store-api.hh" #include "db.hh" +#include "local-store.hh" #include @@ -19,28 +20,33 @@ Derivation derivationFromPath(const Path & drvPath) } void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection) +{ + computeFSClosureTxn(noTxn, path, paths, withComponents, withState, revision, flipDirection); +} + +void computeFSClosureTxn(const Transaction & txn, const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection) { PathSet allPaths; - computeFSClosureRec(path, allPaths, revision, flipDirection); + computeFSClosureRecTxn(txn, path, allPaths, revision, flipDirection); if(!withComponents && !withState) throw Error(format("Useless call to computeFSClosure, at leat withComponents or withState must be true")); //TODO MAYBE EDIT: HOW CAN THESE PATHS ALREADY BE VALID SOMETIMES ..... ????????????????????? for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i) - if ( !store->isValidPath(*i) && !store->isValidStatePath(*i) ) + if ( !isValidPathTxn(txn, *i) && !isValidStatePathTxn(txn, *i) ) throw Error(format("Not a state or store path: ") % *i); //if withState is false, we filter out all state paths if( withComponents && !withState ){ for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i) - if ( store->isValidPath(*i) ) + if ( isValidPathTxn(txn, *i) ) paths.insert(*i); } //if withComponents is false, we filter out all component paths else if( !withComponents && withState ){ for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i) - if ( store->isValidStatePath(*i) ) + if ( isValidStatePathTxn(txn, *i) ) paths.insert(*i); } //all @@ -49,7 +55,7 @@ void computeFSClosure(const Path & path, PathSet & paths, const bool & withCompo } } -void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection) +void computeFSClosureRecTxn(const Transaction & txn, const Path & path, PathSet & paths, const int revision, const bool & flipDirection) { if (paths.find(path) != paths.end()) return; //takes care of double entries @@ -59,19 +65,19 @@ void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, PathSet stateReferences; if (flipDirection){ - store->queryReferrers(path, references, revision); - store->queryStateReferrers(path, stateReferences, revision); + queryReferrersTxn(txn, path, references, revision); + queryStateReferrersTxn(txn, path, stateReferences, revision); } else{ - store->queryReferences(path, references, revision); - store->queryStateReferences(path, stateReferences, revision); + queryReferencesTxn(txn, path, references, revision); + queryStateReferencesTxn(txn, path, stateReferences, revision); } PathSet allReferences; allReferences = pathSets_union(references, stateReferences); for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i) - computeFSClosureRec(*i, paths, revision, flipDirection); + computeFSClosureRecTxn(txn, *i, paths, revision, flipDirection); } diff --git a/src/libstore/misc.hh b/src/libstore/misc.hh index 3d991faf1..75446e5e4 100644 --- a/src/libstore/misc.hh +++ b/src/libstore/misc.hh @@ -2,6 +2,7 @@ #define __MISC_H #include "derivations.hh" +#include "db.hh" namespace nix { @@ -26,7 +27,9 @@ Derivation derivationFromPath(const Path & drvPath); returned. */ void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection = false); -void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection); //TODO private +void computeFSClosureTxn(const Transaction & txn, const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection = false); + +void computeFSClosureRecTxn(const Transaction & txn, const Path & path, PathSet & paths, const int revision, const bool & flipDirection); //TODO private /* Return the path corresponding to the output identifier `id' in the given derivation. */ diff --git a/src/libstore/store-state.cc b/src/libstore/store-state.cc index d3d7ca27c..1a3e73f60 100644 --- a/src/libstore/store-state.cc +++ b/src/libstore/store-state.cc @@ -202,7 +202,7 @@ void updateRevisionsRecursivelyTxn(const Transaction & txn, const Path & statePa RevisionNumbersSet rivisionMapping; PathSet statePaths; - storePathRequisites(statePath, false, statePaths, false, true, -1); //Get all current state dependencies + storePathRequisitesTxn(txn, statePath, false, statePaths, false, true, -1); //Get all current state dependencies //Add own statePath (may already be in there, but its a set, so no doubles) statePaths.insert(statePath);