mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
runProgram backup
This commit is contained in:
parent
eb1f179eac
commit
4f483aad0f
16 changed files with 338 additions and 174 deletions
|
|
@ -1083,7 +1083,7 @@ static string makeValidityRegistration(const PathSet & paths,
|
|||
s += deriver + "\n";
|
||||
|
||||
PathSet references;
|
||||
store->queryReferences(*i, references);
|
||||
store->queryReferences(*i, references, -1); //TODO check if this is ok
|
||||
|
||||
s += (format("%1%\n") % references.size()).str();
|
||||
|
||||
|
|
@ -2018,7 +2018,7 @@ void SubstitutionGoal::init()
|
|||
|
||||
/* To maintain the closure invariant, we first have to realise the
|
||||
paths referenced by this one. */
|
||||
store->queryReferences(storePath, references);
|
||||
store->queryReferences(storePath, references, -1);
|
||||
|
||||
for (PathSet::iterator i = references.begin();
|
||||
i != references.end(); ++i)
|
||||
|
|
|
|||
|
|
@ -444,11 +444,47 @@ void Database::enumTable(const Transaction & txn, TableId table,
|
|||
} catch (DbException e) { rethrow(e); }
|
||||
}
|
||||
|
||||
/* State specific db functions */
|
||||
|
||||
Path Database::makeStatePathRevision(const Path & statePath, const int revision)
|
||||
{
|
||||
string prefix = "-REV-";
|
||||
|
||||
return statePath + prefix + int2String(revision);
|
||||
}
|
||||
void Database::splitStatePathRevision(const Path & revisionedStatePath, Path & statePath, int & revision)
|
||||
{
|
||||
string prefix = "-REV-";
|
||||
|
||||
int pos = revisionedStatePath.find_last_not_of(prefix);
|
||||
statePath = revisionedStatePath.substr(0, pos - prefix.length());
|
||||
//printMsg(lvlError, format("'%1%' '%2%'") % statePath % revisionedStatePath.substr(pos, revisionedStatePath.size()));
|
||||
bool succeed = string2Int(revisionedStatePath.substr(pos, revisionedStatePath.size()), revision);
|
||||
if(!succeed)
|
||||
throw Error(format("Malformed revision value of path '%1%'") % revisionedStatePath);
|
||||
}
|
||||
|
||||
|
||||
void Database::setStateReferences(const Transaction & txn, TableId table,
|
||||
const Path & statePath, const int revision, const Strings & references)
|
||||
{
|
||||
//printMsg(lvlError, format("setStateReferences/Referrers %1%") % table);
|
||||
|
||||
if(revision == -1)
|
||||
throw Error("-1 is not a valid revision value for SET-references/referrers");
|
||||
|
||||
/*
|
||||
for (Strings::const_iterator i = references.begin(); i != references.end(); ++i)
|
||||
printMsg(lvlError, format("setStateReferences::: '%1%'") % *i);
|
||||
*/
|
||||
|
||||
//Warning if it already exists
|
||||
Strings empty;
|
||||
if( queryStateReferences(txn, table, statePath, empty, revision) )
|
||||
printMsg(lvlError, format("Warning: The revision '%1%' already exists for set-references/referrers of path '%2%' with db '%3%'") % revision % statePath % table);
|
||||
|
||||
//Create the key
|
||||
string key = statePath + "-" + int2String(revision);
|
||||
string key = makeStatePathRevision(statePath, revision);
|
||||
|
||||
//Insert
|
||||
setStrings(txn, table, key, references);
|
||||
|
|
@ -457,43 +493,59 @@ void Database::setStateReferences(const Transaction & txn, TableId table,
|
|||
bool Database::queryStateReferences(const Transaction & txn, TableId table,
|
||||
const Path & statePath, Strings & references, int revision)
|
||||
{
|
||||
//printMsg(lvlError, format("queryStateReferences/Referrers %1%") % table);
|
||||
|
||||
Strings keys;
|
||||
enumTable(txn, table, keys); //get all revisions
|
||||
|
||||
string key = ""; //final key that matches revision + statePath
|
||||
string key = ""; //final key that matches revision + statePath
|
||||
int highestRev = -1;
|
||||
|
||||
//Lookup which key we need
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i) {
|
||||
string getStatePath = *i;
|
||||
Path getStatePath_org = *i;
|
||||
Path getStatePath;
|
||||
int getRevision;
|
||||
splitStatePathRevision(*i, getStatePath, getRevision);
|
||||
|
||||
if(getStatePath.substr(0, statePath.size()) == statePath){
|
||||
int getRev;
|
||||
bool succeed = string2Int(getStatePath.substr(statePath.size() + 1, getStatePath.size()), getRev);
|
||||
if(!succeed)
|
||||
throw Error("Malformed revision value after statePath in stateRefereneces");
|
||||
|
||||
printMsg(lvlError, format("KEY: %1% of %2%") % getStatePath % getRev);
|
||||
if(getStatePath == statePath){
|
||||
|
||||
if(revision == -1){ //the user wants the last revision
|
||||
if(getRev > highestRev)
|
||||
highestRev = getRev;
|
||||
if(getRevision > highestRev)
|
||||
highestRev = getRevision;
|
||||
}
|
||||
else if(revision == getRev){
|
||||
key = getStatePath;
|
||||
else if(revision == getRevision){
|
||||
key = getStatePath_org;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(key == "" && highestRev == -1) //no records found
|
||||
if(key == "" && highestRev == -1) //no records found (TODO throw error?)
|
||||
return false;
|
||||
|
||||
if(revision == -1)
|
||||
key = statePath + "-" + int2String(highestRev);
|
||||
key = makeStatePathRevision(statePath, highestRev);
|
||||
|
||||
return queryStrings(txn, table, key, references); //now that we have the key, we can query the references
|
||||
}
|
||||
}
|
||||
|
||||
bool Database::queryStateReferrers(const Transaction & txn, TableId table,
|
||||
const Path & statePath, Strings & referrers, int revision)
|
||||
{
|
||||
//PathSet referrers;
|
||||
Strings keys;
|
||||
Path revisionedStatePath = makeStatePathRevision(statePath, revision);
|
||||
|
||||
enumTable(txn, table, keys, revisionedStatePath + string(1, (char) 0));
|
||||
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i)
|
||||
printMsg(lvlError, format("queryStateReferrers %1%") % *i);
|
||||
//referrers.insert(stripPrefix(storePath, *i));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Database::setStateRevisions(const Transaction & txn, TableId table,
|
||||
const Path & statePath, const int revision, const RevisionNumbers & revisions)
|
||||
|
|
|
|||
|
|
@ -90,6 +90,12 @@ public:
|
|||
void enumTable(const Transaction & txn, TableId table,
|
||||
Strings & keys, const string & keyPrefix = "");
|
||||
|
||||
/* TODO */
|
||||
Path makeStatePathRevision(const Path & statePath, const int revision);
|
||||
|
||||
/* TODO */
|
||||
void splitStatePathRevision(const Path & revisionedStatePath, Path & statePath, int & revision);
|
||||
|
||||
/* Set the stateReferences for a specific revision (and older until the next higher revision number in the table) */
|
||||
void setStateReferences(const Transaction & txn, TableId table,
|
||||
const Path & statePath, const int revision, const Strings & references);
|
||||
|
|
@ -98,6 +104,10 @@ public:
|
|||
bool queryStateReferences(const Transaction & txn, TableId table,
|
||||
const Path & statePath, Strings & references, int revision = -1);
|
||||
|
||||
/* Returns the referrers for a specific revision (and older until the next higher revision number in the table) */
|
||||
bool queryStateReferrers(const Transaction & txn, TableId table,
|
||||
const Path & statePath, Strings & referrers, int revision = -1);
|
||||
|
||||
/* Set the revision number of the statePath and the revision numbers of all state paths in the references closure */
|
||||
void setStateRevisions(const Transaction & txn, TableId table,
|
||||
const Path & statePath, const int revision, const RevisionNumbers & revisions);
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ static void dfsVisit(const PathSet & paths, const Path & path,
|
|||
|
||||
PathSet references;
|
||||
if (store->isValidPath(path))
|
||||
store->queryReferences(path, references);
|
||||
store->queryReferences(path, references, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
for (PathSet::iterator i = references.begin();
|
||||
i != references.end(); ++i)
|
||||
|
|
|
|||
|
|
@ -387,40 +387,51 @@ static string stripPrefix(const string & prefix, const string & s)
|
|||
}
|
||||
|
||||
|
||||
static PathSet getReferrers(const Transaction & txn, const Path & storePath)
|
||||
//TODO move the code of get(State)Referrers into query variant ..... !!!!!!!!!!!!!!!!!!!!!!!!!!!!???
|
||||
|
||||
|
||||
static PathSet getReferrers(const Transaction & txn, const Path & store_or_statePath, const int revision)
|
||||
{
|
||||
PathSet referrers;
|
||||
Strings keys;
|
||||
|
||||
if(isValidPathTxn(txn, storePath))
|
||||
nixDB.enumTable(txn, dbComponentComponentReferrers, keys, storePath + string(1, (char) 0));
|
||||
else if(isValidStatePathTxn(txn, storePath))
|
||||
nixDB.enumTable(txn, dbStateComponentReferrers, keys, storePath + string(1, (char) 0));
|
||||
if(isValidPathTxn(txn, store_or_statePath)){
|
||||
PathSet referrers;
|
||||
Strings keys;
|
||||
nixDB.enumTable(txn, dbComponentComponentReferrers, keys, store_or_statePath + string(1, (char) 0));
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i)
|
||||
referrers.insert(stripPrefix(store_or_statePath, *i));
|
||||
return referrers;
|
||||
}
|
||||
else if(isValidStatePathTxn(txn, store_or_statePath)){
|
||||
Paths referrers;
|
||||
nixDB.queryStateReferrers(txn, dbStateComponentReferrers, store_or_statePath, referrers, revision);
|
||||
PathSet p(referrers.begin(), referrers.end());
|
||||
return p;
|
||||
}
|
||||
else
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % storePath);
|
||||
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i)
|
||||
referrers.insert(stripPrefix(storePath, *i));
|
||||
return referrers;
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % store_or_statePath);
|
||||
|
||||
}
|
||||
|
||||
static PathSet getStateReferrers(const Transaction & txn, const Path & storePath) //TODO this is just a copy of getReferrers with a change to dbStateReferrers, maybe make the function more generic?
|
||||
static PathSet getStateReferrers(const Transaction & txn, const Path & store_or_statePath, const int revision) //TODO this is just a copy of getReferrers with a change to dbStateReferrers, maybe make the function more generic?
|
||||
{
|
||||
PathSet referrers;
|
||||
Strings keys;
|
||||
|
||||
if(isValidPathTxn(txn, storePath))
|
||||
nixDB.enumTable(txn, dbComponentComponentReferrers, keys, storePath + string(1, (char) 0));
|
||||
else if(isValidStatePathTxn(txn, storePath))
|
||||
nixDB.enumTable(txn, dbStateComponentReferrers, keys, storePath + string(1, (char) 0));
|
||||
if(isValidPathTxn(txn, store_or_statePath)){
|
||||
PathSet referrers;
|
||||
Strings keys;
|
||||
nixDB.enumTable(txn, dbComponentStateReferrers, keys, store_or_statePath + string(1, (char) 0));
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i)
|
||||
referrers.insert(stripPrefix(store_or_statePath, *i));
|
||||
return referrers;
|
||||
}
|
||||
else if(isValidStatePathTxn(txn, store_or_statePath)){
|
||||
Paths referrers;
|
||||
nixDB.queryStateReferrers(txn, dbStateStateReferrers, store_or_statePath, referrers, revision);
|
||||
PathSet p(referrers.begin(), referrers.end());
|
||||
return p;
|
||||
}
|
||||
else
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % storePath);
|
||||
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i)
|
||||
referrers.insert(stripPrefix(storePath, *i));
|
||||
return referrers;
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % store_or_statePath);
|
||||
}
|
||||
|
||||
|
||||
void setReferences(const Transaction & txn, const Path & store_or_statePath,
|
||||
const PathSet & references, const PathSet & stateReferences, const int revision)
|
||||
{
|
||||
|
|
@ -440,7 +451,7 @@ void setReferences(const Transaction & txn, const Path & store_or_statePath,
|
|||
PathSet oldStateReferences2;
|
||||
Paths oldReferences_X_c;
|
||||
Paths oldReferences_X_s;
|
||||
|
||||
|
||||
if(isRealisablePath(txn, store_or_statePath))
|
||||
{
|
||||
Paths oldReferences_c_c;
|
||||
|
|
@ -467,16 +478,15 @@ void setReferences(const Transaction & txn, const Path & store_or_statePath,
|
|||
Paths oldStateReferences_s_c;
|
||||
Paths oldStateReferences_s_s;
|
||||
|
||||
nixDB.queryStrings(txn, dbStateComponentReferences, store_or_statePath, oldStateReferences_s_c);
|
||||
nixDB.queryStrings(txn, dbStateStateReferences, store_or_statePath, oldStateReferences_s_s);
|
||||
|
||||
nixDB.queryStateReferences(txn, dbStateComponentReferences, store_or_statePath, oldStateReferences_s_c, revision);
|
||||
nixDB.queryStateReferences(txn, dbStateStateReferences, store_or_statePath, oldStateReferences_s_s, revision);
|
||||
|
||||
oldReferences2 = PathSet(oldStateReferences_s_c.begin(), oldStateReferences_s_c.end());
|
||||
oldStateReferences2 = PathSet(oldStateReferences_s_s.begin(), oldStateReferences_s_s.end());
|
||||
if (oldReferences2 == references && oldStateReferences2 == stateReferences) return;
|
||||
|
||||
nixDB.setStrings(txn, dbStateComponentReferences, store_or_statePath, Paths(references.begin(), references.end()));
|
||||
nixDB.setStateReferences(txn, dbStateStateReferences, store_or_statePath, revision, Paths(stateReferences.begin(), stateReferences.end()));
|
||||
|
||||
nixDB.setStateReferences(txn, dbStateComponentReferences, store_or_statePath, revision, Paths(references.begin(), references.end()));
|
||||
nixDB.setStateReferences(txn, dbStateStateReferences, store_or_statePath, revision, Paths(stateReferences.begin(), stateReferences.end()));
|
||||
|
||||
//set vars for the referrers update code below
|
||||
dbXComponentReferrers = dbStateComponentReferrers;
|
||||
dbXStateReferrers = dbStateStateReferrers;
|
||||
|
|
@ -486,102 +496,104 @@ void setReferences(const Transaction & txn, const Path & store_or_statePath,
|
|||
else
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % store_or_statePath);
|
||||
|
||||
//The follow 4 for-loops haved been made generic with variables, they work in the case of statePaths and storePaths
|
||||
|
||||
//store_or_statePath must be postfixed in case it is a statePath
|
||||
Path store_or_statePath2 = store_or_statePath;
|
||||
if(isRealisableStatePath(txn, store_or_statePath))
|
||||
store_or_statePath2 = nixDB.makeStatePathRevision(store_or_statePath, revision);
|
||||
|
||||
//The follow 4 for-loops haved been made generic with variables, they work in the case of statePaths and storePaths
|
||||
|
||||
/* Update the referrers mappings of all new referenced paths. */
|
||||
for (PathSet::const_iterator i = references.begin(); i != references.end(); ++i)
|
||||
if (oldReferences2.find(*i) == oldReferences2.end())
|
||||
nixDB.setString(txn, dbXComponentReferrers, addPrefix(*i, store_or_statePath), "");
|
||||
nixDB.setString(txn, dbXComponentReferrers, addPrefix(*i, store_or_statePath2), "");
|
||||
|
||||
/* Remove referrer mappings from paths that are no longer references. */
|
||||
for (Paths::iterator i = oldReferences_X_c.begin(); i != oldReferences_X_c.end(); ++i)
|
||||
if (references.find(*i) == references.end())
|
||||
nixDB.delPair(txn, dbXComponentReferrers, addPrefix(*i, store_or_statePath));
|
||||
nixDB.delPair(txn, dbXComponentReferrers, addPrefix(*i, store_or_statePath2));
|
||||
|
||||
/* Update the state referrers mappings of all new referenced paths. */
|
||||
for (PathSet::const_iterator i = stateReferences.begin(); i != stateReferences.end(); ++i)
|
||||
if (oldStateReferences2.find(*i) == oldStateReferences2.end())
|
||||
nixDB.setString(txn, dbXStateReferrers, addPrefix(*i, store_or_statePath), "");
|
||||
nixDB.setString(txn, dbXStateReferrers, addPrefix(*i, store_or_statePath2), "");
|
||||
|
||||
/* Remove referrer mappings from paths that are no longer state references. */
|
||||
for (Paths::iterator i = oldReferences_X_s.begin(); i != oldReferences_X_s.end(); ++i)
|
||||
if (stateReferences.find(*i) == stateReferences.end())
|
||||
nixDB.delPair(txn, dbXStateReferrers, addPrefix(*i, store_or_statePath));
|
||||
|
||||
nixDB.delPair(txn, dbXStateReferrers, addPrefix(*i, store_or_statePath2));
|
||||
}
|
||||
|
||||
|
||||
void queryReferences(const Transaction & txn,
|
||||
const Path & storePath, PathSet & references)
|
||||
const Path & store_or_statePath, PathSet & references, const int revision)
|
||||
{
|
||||
Paths references2;
|
||||
|
||||
if(isRealisablePath(txn, storePath))
|
||||
nixDB.queryStrings(txn, dbComponentComponentReferences, storePath, references2);
|
||||
else if(isRealisableStatePath(txn, storePath))
|
||||
nixDB.queryStrings(txn, dbStateComponentReferences, storePath, references2);
|
||||
if(isRealisablePath(txn, store_or_statePath))
|
||||
nixDB.queryStrings(txn, dbComponentComponentReferences, store_or_statePath, references2);
|
||||
else if(isRealisableStatePath(txn, store_or_statePath))
|
||||
nixDB.queryStateReferences(txn, dbStateComponentReferences, store_or_statePath, references2, revision);
|
||||
else
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % storePath);
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % store_or_statePath);
|
||||
|
||||
references.insert(references2.begin(), references2.end());
|
||||
}
|
||||
|
||||
|
||||
void LocalStore::queryReferences(const Path & storePath,
|
||||
PathSet & references)
|
||||
PathSet & references, const int revision)
|
||||
{
|
||||
nix::queryReferences(noTxn, storePath, references);
|
||||
nix::queryReferences(noTxn, storePath, references, revision);
|
||||
}
|
||||
|
||||
void queryStateReferences(const Transaction & txn,
|
||||
const Path & componentOrstatePath, PathSet & stateReferences)
|
||||
const Path & store_or_statePath, PathSet & stateReferences, const int revision)
|
||||
{
|
||||
Paths stateReferences2;
|
||||
|
||||
if(isRealisablePath(txn, componentOrstatePath))
|
||||
nixDB.queryStrings(txn, dbComponentStateReferences, componentOrstatePath, stateReferences2);
|
||||
else if(isRealisableStatePath(txn, componentOrstatePath))
|
||||
nixDB.queryStrings(txn, dbStateStateReferences, componentOrstatePath, stateReferences2); //TODO !!!!!!!!!!!!!!!! state-state references are not strings anymore !!!!
|
||||
if(isRealisablePath(txn, store_or_statePath))
|
||||
nixDB.queryStrings(txn, dbComponentStateReferences, store_or_statePath, stateReferences2);
|
||||
else if(isRealisableStatePath(txn, store_or_statePath))
|
||||
nixDB.queryStateReferences(txn, dbStateStateReferences, store_or_statePath, stateReferences2, revision);
|
||||
else
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % componentOrstatePath);
|
||||
throw Error(format("Path '%1%' is not a valid component or state path") % store_or_statePath);
|
||||
|
||||
stateReferences.insert(stateReferences2.begin(), stateReferences2.end());
|
||||
}
|
||||
|
||||
void LocalStore::queryStateReferences(const Path & componentOrstatePath, PathSet & stateReferences)
|
||||
void LocalStore::queryStateReferences(const Path & componentOrstatePath, PathSet & stateReferences, const int revision)
|
||||
{
|
||||
nix::queryStateReferences(noTxn, componentOrstatePath, stateReferences);
|
||||
nix::queryStateReferences(noTxn, componentOrstatePath, stateReferences, revision);
|
||||
}
|
||||
|
||||
void queryReferrers(const Transaction & txn,
|
||||
const Path & storePath, PathSet & referrers)
|
||||
const Path & storePath, PathSet & referrers, const int revision)
|
||||
{
|
||||
if (!isRealisableComponentOrStatePath(txn, storePath))
|
||||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
PathSet referrers2 = getReferrers(txn, storePath);
|
||||
PathSet referrers2 = getReferrers(txn, storePath, revision);
|
||||
referrers.insert(referrers2.begin(), referrers2.end());
|
||||
}
|
||||
|
||||
|
||||
void LocalStore::queryReferrers(const Path & storePath,
|
||||
PathSet & referrers)
|
||||
PathSet & referrers, const int revision)
|
||||
{
|
||||
nix::queryReferrers(noTxn, storePath, referrers);
|
||||
nix::queryReferrers(noTxn, storePath, referrers, revision);
|
||||
}
|
||||
|
||||
|
||||
void queryStateReferrers(const Transaction & txn, const Path & storePath, PathSet & stateReferrers)
|
||||
void queryStateReferrers(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision)
|
||||
{
|
||||
if (!isRealisableComponentOrStatePath(txn, storePath))
|
||||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
PathSet stateReferrers2 = getStateReferrers(txn, storePath);
|
||||
PathSet stateReferrers2 = getStateReferrers(txn, storePath, revision);
|
||||
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
|
||||
}
|
||||
|
||||
|
||||
void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers)
|
||||
void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers, const int revision)
|
||||
{
|
||||
nix::queryStateReferrers(noTxn, storePath, stateReferrers);
|
||||
nix::queryStateReferrers(noTxn, storePath, stateReferrers, revision);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -630,11 +642,9 @@ void addStateDeriver(const Transaction & txn, const Path & storePath, const Path
|
|||
|
||||
}
|
||||
|
||||
//TODO Add and ..
|
||||
bool isStateComponentTxn(const Transaction & txn, const Path & storePath)
|
||||
{
|
||||
isValidPathTxn(txn, storePath);
|
||||
|
||||
string data;
|
||||
return nixDB.queryString(txn, dbStateInfo, storePath, data);
|
||||
}
|
||||
|
|
@ -645,12 +655,10 @@ bool LocalStore::isStateComponent(const Path & storePath)
|
|||
}
|
||||
|
||||
|
||||
//TODO Add and ..
|
||||
bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath)
|
||||
{
|
||||
printMsg(lvlError, format("Sssssssssssssssssss %1%") % drvPath);
|
||||
Derivation drv = derivationFromPath(drvPath);
|
||||
printMsg(lvlError, format("uuuuuuuuuuuuuuuuuu %1%") % drvPath);
|
||||
return isStateDrvTxn(txn, drv);
|
||||
}
|
||||
|
||||
|
|
@ -659,7 +667,6 @@ bool LocalStore::isStateDrvPath(const Path & isStateDrv)
|
|||
return nix::isStateDrvPathTxn(noTxn, isStateDrv);
|
||||
}
|
||||
|
||||
//TODO Add and ..
|
||||
bool isStateDrvTxn(const Transaction & txn, const Derivation & drv)
|
||||
{
|
||||
if (drv.stateOutputs.size() != 0)
|
||||
|
|
@ -1114,7 +1121,7 @@ void LocalStore::exportPath(const Path & path, bool sign,
|
|||
writeString(path, hashAndWriteSink);
|
||||
|
||||
PathSet references;
|
||||
nix::queryReferences(txn, path, references);
|
||||
nix::queryReferences(txn, path, references, -1); //TODO we can only now export the final revision
|
||||
writeStringSet(references, hashAndWriteSink);
|
||||
|
||||
Path deriver = queryDeriver(txn, path);
|
||||
|
|
@ -1277,7 +1284,7 @@ void deleteFromStore(const Path & _path, unsigned long long & bytesFreed)
|
|||
|
||||
Transaction txn(nixDB);
|
||||
if (isValidPathTxn(txn, path)) {
|
||||
PathSet referrers = getReferrers(txn, path);
|
||||
PathSet referrers = getReferrers(txn, path, -1); //delete latest referrers (TODO?)
|
||||
for (PathSet::iterator i = referrers.begin();
|
||||
i != referrers.end(); ++i)
|
||||
if (*i != path && isValidPathTxn(txn, *i))
|
||||
|
|
@ -1396,7 +1403,7 @@ void verifyStore(bool checkContents)
|
|||
else {
|
||||
bool isValid = validPaths.find(*i) != validPaths.end();
|
||||
PathSet references;
|
||||
queryReferences(txn, *i, references);
|
||||
queryReferences(txn, *i, references, -1); //TODO
|
||||
for (PathSet::iterator j = references.begin();
|
||||
j != references.end(); ++j)
|
||||
{
|
||||
|
|
@ -1445,10 +1452,10 @@ void verifyStore(bool checkContents)
|
|||
|
||||
else {
|
||||
PathSet references;
|
||||
queryReferences(txn, from, references);
|
||||
queryReferences(txn, from, references, -1); //TODO
|
||||
|
||||
PathSet stateReferences; //already a stateReferrers here!
|
||||
queryStateReferences(txn, from, stateReferences);
|
||||
queryStateReferences(txn, from, stateReferences, -1); //TODO CHECK FOR ALL REVISIONS !
|
||||
|
||||
if (find(references.begin(), references.end(), to) == references.end()) {
|
||||
printMsg(lvlError, format("adding missing referrer mapping from `%1%' to `%2%'") % from % to);
|
||||
|
|
@ -1702,8 +1709,8 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
|||
//Retrieve old references
|
||||
PathSet old_references;
|
||||
PathSet old_state_references;
|
||||
queryReferences(txn, statePath, old_references);
|
||||
queryStateReferences(txn, statePath, old_state_references);
|
||||
queryReferences(txn, statePath, old_references, -1); //get the latsest references
|
||||
queryStateReferences(txn, statePath, old_state_references, -1);
|
||||
|
||||
//Check for added and removed paths
|
||||
PathSet diff_references_removed;
|
||||
|
|
@ -1872,7 +1879,7 @@ static void upgradeStore07()
|
|||
}
|
||||
|
||||
PathSet prevReferences;
|
||||
queryReferences(txn, path, prevReferences);
|
||||
queryReferences(txn, path, prevReferences, -1);
|
||||
if (prevReferences.size() > 0 && references != prevReferences)
|
||||
printMsg(lvlError, format("warning: conflicting references for `%1%'") % path);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ public:
|
|||
|
||||
Path queryStatePathDrv(const Path & statePath);
|
||||
|
||||
void queryReferences(const Path & path, PathSet & references);
|
||||
void queryReferences(const Path & path, PathSet & references, const int revision);
|
||||
|
||||
void queryStateReferences(const Path & storePath, PathSet & stateReferences);
|
||||
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
|
||||
|
||||
void queryReferrers(const Path & path, PathSet & referrers);
|
||||
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
|
||||
|
||||
void queryStateReferrers(const Path & path, PathSet & stateReferrers);
|
||||
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
|
||||
|
||||
Path addToStore(const Path & srcPath, bool fixed = false,
|
||||
bool recursive = false, string hashAlgo = "",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ namespace nix {
|
|||
Derivation derivationFromPath(const Path & drvPath)
|
||||
{
|
||||
assertStorePath(drvPath);
|
||||
printMsg(lvlError, format("tttttttttttttttttt"));
|
||||
store->ensurePath(drvPath);
|
||||
printMsg(lvlError, format("uuuuuuuuuuuuuuuuuu"));
|
||||
ATerm t = ATreadFromNamedFile(drvPath.c_str());
|
||||
if (!t) throw Error(format("cannot read aterm from `%1%'") % drvPath);
|
||||
return parseDerivation(t);
|
||||
|
|
@ -58,12 +60,12 @@ void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDi
|
|||
PathSet stateReferences;
|
||||
|
||||
if (flipDirection){
|
||||
store->queryReferrers(path, references);
|
||||
store->queryStateReferrers(path, stateReferences);
|
||||
store->queryReferrers(path, references, -1);
|
||||
store->queryStateReferrers(path, stateReferences, -1);
|
||||
}
|
||||
else{
|
||||
store->queryReferences(path, references);
|
||||
store->queryStateReferences(path, stateReferences);
|
||||
store->queryReferences(path, references, -1);
|
||||
store->queryStateReferences(path, stateReferences, -1);
|
||||
}
|
||||
|
||||
PathSet allReferences;
|
||||
|
|
@ -122,7 +124,7 @@ void queryMissing(const PathSet & targets,
|
|||
if (store->hasSubstitutes(p))
|
||||
willSubstitute.insert(p);
|
||||
PathSet refs;
|
||||
store->queryReferences(p, todo);
|
||||
store->queryReferences(p, todo, -1); //TODO?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,10 @@ Derivation derivationFromPath(const Path & drvPath);
|
|||
`storePath' is returned; that is, the closures under the
|
||||
`referrers' relation instead of the `references' relation is
|
||||
|
||||
withState = TODO comment
|
||||
withComponents = TODO
|
||||
withState = include the state paths into the closure
|
||||
withComponents = include the component paths into the closure
|
||||
|
||||
We can currentky only compute the closure of the latsest revision!
|
||||
|
||||
returned. */
|
||||
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection = false);
|
||||
|
|
|
|||
|
|
@ -216,44 +216,49 @@ Path RemoteStore::queryStatePathDrv(const Path & statePath)
|
|||
}
|
||||
|
||||
void RemoteStore::queryReferences(const Path & path,
|
||||
PathSet & references)
|
||||
PathSet & references, const int revision)
|
||||
{
|
||||
writeInt(wopQueryReferences, to);
|
||||
writeString(path, to);
|
||||
processStderr();
|
||||
PathSet references2 = readStorePaths(from);
|
||||
references.insert(references2.begin(), references2.end());
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
||||
}
|
||||
|
||||
void RemoteStore::queryStateReferences(const Path & path,
|
||||
PathSet & stateReferences)
|
||||
PathSet & stateReferences, const int revision)
|
||||
{
|
||||
writeInt(wopQueryStateReferences, to);
|
||||
writeString(path, to);
|
||||
processStderr();
|
||||
PathSet stateReferences2 = readStorePaths(from);
|
||||
stateReferences.insert(stateReferences2.begin(), stateReferences2.end());
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RemoteStore::queryReferrers(const Path & path,
|
||||
PathSet & referrers)
|
||||
PathSet & referrers, const int revision)
|
||||
{
|
||||
writeInt(wopQueryReferrers, to);
|
||||
writeString(path, to);
|
||||
processStderr();
|
||||
PathSet referrers2 = readStorePaths(from);
|
||||
referrers.insert(referrers2.begin(), referrers2.end());
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
||||
}
|
||||
|
||||
void RemoteStore::queryStateReferrers(const Path & path, PathSet & stateReferrers)
|
||||
void RemoteStore::queryStateReferrers(const Path & path,
|
||||
PathSet & stateReferrers, const int revision)
|
||||
{
|
||||
writeInt(wopQueryStateReferrers, to);
|
||||
writeString(path, to);
|
||||
processStderr();
|
||||
PathSet stateReferrers2 = readStorePaths(from);
|
||||
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ public:
|
|||
|
||||
Path queryStatePathDrv(const Path & statePath);
|
||||
|
||||
void queryReferences(const Path & path, PathSet & references);
|
||||
void queryReferences(const Path & path, PathSet & references, const int revision);
|
||||
|
||||
void queryStateReferences(const Path & storePath, PathSet & stateReferences);
|
||||
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
|
||||
|
||||
void queryReferrers(const Path & path, PathSet & referrers);
|
||||
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
|
||||
|
||||
void queryStateReferrers(const Path & path, PathSet & stateReferrers);
|
||||
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
|
||||
|
||||
Path addToStore(const Path & srcPath, bool fixed = false,
|
||||
bool recursive = false, string hashAlgo = "",
|
||||
|
|
|
|||
|
|
@ -81,20 +81,20 @@ public:
|
|||
/* Queries the set of outgoing FS references for a store path.
|
||||
The result is not cleared. */
|
||||
virtual void queryReferences(const Path & path,
|
||||
PathSet & references) = 0;
|
||||
PathSet & references, const int revision) = 0;
|
||||
|
||||
/* Queries the set of outgoing FS state-references for a store path.
|
||||
The result is not cleared. */
|
||||
virtual void queryStateReferences(const Path & storePath, PathSet & stateReferences) = 0;
|
||||
virtual void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision) = 0;
|
||||
|
||||
/* Queries the set of incoming FS references for a store path.
|
||||
The result is not cleared. */
|
||||
virtual void queryReferrers(const Path & path,
|
||||
PathSet & referrers) = 0;
|
||||
PathSet & referrers, const int revision) = 0;
|
||||
|
||||
/* Queries the set of incoming FS state-references for a store path.
|
||||
The result is not cleared. */
|
||||
virtual void queryStateReferrers(const Path & path, PathSet & stateReferrers) = 0;
|
||||
virtual void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision) = 0;
|
||||
|
||||
/* Copy the contents of a path to the store and register the
|
||||
validity the resulting path. The resulting path is returned.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue