mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
Fixed bugs, cleaned up some code
This commit is contained in:
parent
afb445957d
commit
bc2fbabc12
6 changed files with 74 additions and 57 deletions
|
|
@ -546,32 +546,35 @@ bool Database::queryStateReferences(const Transaction & txn, TableId table,
|
|||
Strings keys;
|
||||
enumTable(txn, table, keys); //get all revisions
|
||||
|
||||
string key;
|
||||
if(revision == -1){
|
||||
//Check if this revision exists key in the table
|
||||
string key = makeStatePathRevision(statePath, revision);
|
||||
bool found = false;
|
||||
for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i) {
|
||||
if(key == *i)
|
||||
found = true;
|
||||
}
|
||||
|
||||
key = ""; //reset
|
||||
if(revision == -1 || (!found)){
|
||||
bool foundsomething = lookupHighestRevivison(keys, statePath, key);
|
||||
if(!foundsomething)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
key = makeStatePathRevision(statePath, revision);
|
||||
|
||||
if(!found)
|
||||
printMsg(lvlError, format("Warning: References for revision '%1%' not was not found, so taking the highest rev-key possible for statePath '%2%'") % revision % statePath);
|
||||
|
||||
|
||||
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;
|
||||
//Exactly the same as queryStateReferences
|
||||
return queryStateReferences(txn, table, statePath, referrers, revision);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -591,10 +594,8 @@ void Database::setStateRevisions(const Transaction & txn, TableId table,
|
|||
sorted_revisions.push_back(revisions.at(*i));
|
||||
|
||||
//////////////////
|
||||
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i){
|
||||
for (vector<Path>::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
|
||||
|
|
@ -639,6 +640,9 @@ bool Database::queryStateRevisions(const Transaction & txn, TableId table,
|
|||
revisions.push_back(getRevision);
|
||||
}
|
||||
|
||||
if(!succeed)
|
||||
throw Error(format("Revision '%1%' not found of statePath '%2%'") % int2String(revision) % statePath);
|
||||
|
||||
return succeed;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ void setReferences(const Transaction & txn, const Path & store_or_statePath,
|
|||
if (references.size() > 0 && !isRealisableComponentOrStatePath(txn, store_or_statePath))
|
||||
throw Error(format("cannot set references for path `%1%' which is invalid and has no substitutes") % store_or_statePath);
|
||||
|
||||
printMsg(lvlError, format("Setting references for %1%") % store_or_statePath);
|
||||
printMsg(lvlError, format("Setting references for %1% (revision:%2%)") % store_or_statePath % int2String(revision));
|
||||
for (PathSet::iterator i = references.begin(); i != references.end(); ++i)
|
||||
printMsg(lvlError, format("'%2%' has references: %1%") % *i % store_or_statePath);
|
||||
for (PathSet::iterator i = stateReferences.begin(); i != stateReferences.end(); ++i)
|
||||
|
|
@ -1598,8 +1598,6 @@ 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)
|
||||
{
|
||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
computeFSClosure(storeOrstatePath, paths, withComponents, withState, revision);
|
||||
|
||||
if (includeOutputs) {
|
||||
|
|
@ -1752,10 +1750,7 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
|||
|
||||
/*
|
||||
Register Valid again if neccesary
|
||||
update the extra references in a new table??? why???
|
||||
(remember we need to keep the old as the basis, and things can change, the db is not consistent anymore then ....)
|
||||
But we also dont want useless refereces ......
|
||||
|
||||
|
||||
Update the 2 references tables: all state paths get: Path statepath --> List(int revnumber, List(References))
|
||||
TODO EDIT TABLES references,references_state,referrers,referrers_state
|
||||
|
||||
|
|
@ -1783,9 +1778,9 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
|||
Hash(), //emtpy hash
|
||||
state_references,
|
||||
state_stateReferences,
|
||||
drvPath);
|
||||
}
|
||||
*/
|
||||
drvPath
|
||||
);
|
||||
}*/
|
||||
}
|
||||
|
||||
void LocalStore::scanAndUpdateAllReferences(const Path & statePath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue