mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 12:10:59 +01:00
State paths can now be scanned and queryed (references), referres still need to be added
This commit is contained in:
parent
5164a77aab
commit
235c91dd7f
6 changed files with 40 additions and 31 deletions
|
|
@ -775,7 +775,6 @@ void DerivationGoal::haveDerivation()
|
|||
|
||||
//Just before we build the drvs, we already put in the database which component path is a state component path
|
||||
printMsg(lvlError, format("updateAllStateDerivations %1%") % drvPath);
|
||||
store->registerMaybeStatePath(drvPath);
|
||||
|
||||
/* If they are all valid, then we're done. */
|
||||
if (invalidOutputs.size() == 0) {
|
||||
|
|
@ -1745,12 +1744,20 @@ void DerivationGoal::computeClosure()
|
|||
PathSet(),
|
||||
drvPath);
|
||||
}
|
||||
|
||||
//TODO COMMENT
|
||||
|
||||
/*
|
||||
* TODO COMMENT
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
for (DerivationOutputs::iterator i = drv.outputs.begin();
|
||||
i != drv.outputs.end(); ++i)
|
||||
{
|
||||
Path path = i->second.path;
|
||||
|
||||
/* For this state-output path, find the references to other paths contained in it.
|
||||
* Get the state paths (instead of out paths) from all components, and then call
|
||||
* scanForStateReferences().
|
||||
|
|
@ -1759,22 +1766,20 @@ void DerivationGoal::computeClosure()
|
|||
for (PathSet::const_iterator i = allPaths.begin(); i != allPaths.end(); i++){
|
||||
Path componentPath = *i;
|
||||
|
||||
printMsg(lvlError, format("COMP: %1%") % (*i));
|
||||
|
||||
if(store->isStateComponent(componentPath)){
|
||||
//printMsg(lvlError, format("COMP: %1%") % (*i));
|
||||
if(isStateComponentTxn(txn, componentPath)){
|
||||
printMsg(lvlError, format("COMP-STATE: %1%") % (*i));
|
||||
|
||||
PathSet stateRefs = queryDerivers(noTxn, componentPath ,"*",getCallingUserName());
|
||||
PathSet stateRefs = queryDeriversStatePath(txn, componentPath ,"*",getCallingUserName());
|
||||
allStatePaths = mergePathSets(stateRefs, allStatePaths);
|
||||
}
|
||||
}
|
||||
PathSet stateReferences = scanForStateReferences(path, allStatePaths);
|
||||
|
||||
for (PathSet::const_iterator i = allStatePaths.begin(); i != allStatePaths.end(); i++){
|
||||
printMsg(lvlError, format("allStatePaths: %1%") % (*i));
|
||||
debug(format("all possible StatePaths: %1%") % (*i));
|
||||
}
|
||||
for (PathSet::const_iterator i = stateReferences.begin(); i != stateReferences.end(); i++){
|
||||
printMsg(lvlError, format("stateReferences: %1%") % (*i));
|
||||
debug(format("state References scanned: %1%") % (*i));
|
||||
}
|
||||
|
||||
allStateReferences[path] = stateReferences;
|
||||
|
|
|
|||
|
|
@ -485,18 +485,17 @@ void addStateDeriver(const Transaction & txn, const Path & storePath, const Path
|
|||
}
|
||||
|
||||
//TODO Add and ..
|
||||
bool isStateComponent(const Path & storePath)
|
||||
bool isStateComponentTxn(const Transaction & txn, const Path & storePath)
|
||||
{
|
||||
store->isValidPath(storePath);
|
||||
string deriver;
|
||||
|
||||
isValidPathTxn(txn, storePath);
|
||||
|
||||
string data;
|
||||
return nixDB.queryString(noTxn, dbStateInfo, storePath, data);
|
||||
return nixDB.queryString(txn, dbStateInfo, storePath, data);
|
||||
}
|
||||
|
||||
bool LocalStore::isStateComponent(const Path & storePath)
|
||||
{
|
||||
return nix::isStateComponent(storePath);
|
||||
return nix::isStateComponentTxn(noTxn, storePath);
|
||||
}
|
||||
|
||||
//TODO Add and ..
|
||||
|
|
@ -564,6 +563,18 @@ PathSet queryDerivers(const Transaction & txn, const Path & storePath, const str
|
|||
return filtereddata;
|
||||
}
|
||||
|
||||
//TODO Wrapper around converting the drvPath to the statePath
|
||||
PathSet queryDeriversStatePath(const Transaction & txn, const Path & storePath, const string & identifier, const string & user)
|
||||
{
|
||||
PathSet drvs = queryDerivers(txn, storePath, identifier, user);
|
||||
PathSet statePaths;
|
||||
for (PathSet::const_iterator i = drvs.begin(); i != drvs.end(); i++){
|
||||
Derivation drv = derivationFromPath((*i));
|
||||
statePaths.insert(drv.stateOutputs.find("state")->second.statepath);
|
||||
}
|
||||
return statePaths;
|
||||
}
|
||||
|
||||
|
||||
const int substituteVersion = 2;
|
||||
|
||||
|
|
@ -1336,7 +1347,8 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
|||
|
||||
if(identifier == getIdentifier && getUser == user) //only insert if it doenst already exist
|
||||
{
|
||||
if(deleteDrvs){
|
||||
//We also check if it's NOT exactly the same drvpath
|
||||
if(drv != newdrv && deleteDrvs){
|
||||
printMsg(lvlTalkative, format("Deleting decrepated state derivation: %1% with identifier %2% and user %3%") % drv % identifier % user);
|
||||
deletePath(drv); //Deletes the DRV from DISK!
|
||||
}
|
||||
|
|
@ -1352,6 +1364,7 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
|||
/* We register in this database which _component_ paths are state paths
|
||||
* This does not mean these paths are already valid!, you should look in derivivers for that
|
||||
*/
|
||||
/*
|
||||
void registerMaybeStatePath(const Path & drvPath)
|
||||
{
|
||||
if(!isStateDrv(drvPath))
|
||||
|
|
@ -1370,7 +1383,7 @@ void LocalStore::registerMaybeStatePath(const Path & drvPath)
|
|||
{
|
||||
nix::registerMaybeStatePath(drvPath);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
|
||||
static void upgradeStore07()
|
||||
|
|
|
|||
|
|
@ -82,8 +82,6 @@ public:
|
|||
|
||||
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
||||
|
||||
void registerMaybeStatePath(const Path & drvPath);
|
||||
|
||||
bool isStateComponent(const Path & path);
|
||||
|
||||
bool isStateDrv(const Path & drvpath);
|
||||
|
|
@ -159,6 +157,9 @@ Path queryDeriver(const Transaction & txn, const Path & path);
|
|||
deriver has been set. */
|
||||
PathSet queryDerivers(const Transaction & txn, const Path & storePath, const string & identifier, const string & user);
|
||||
|
||||
/* TODO */
|
||||
PathSet queryDeriversStatePath(const Transaction & txn, const Path & storePath, const string & identifier, const string & user);
|
||||
|
||||
/* Delete a value from the nixStore directory. */
|
||||
void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
|
||||
|
||||
|
|
@ -188,6 +189,7 @@ void addStateDeriver(const Transaction & txn, const Path & storePath, const Path
|
|||
/* TODO */
|
||||
PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs = false);
|
||||
|
||||
bool isStateComponentTxn(const Transaction & txn, const Path & path);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -402,12 +402,6 @@ vector<int> RemoteStore::getStatePathsInterval(const PathSet & statePaths)
|
|||
return intervals;
|
||||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::registerMaybeStatePath(const Path & drvPath)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool RemoteStore::isStateComponent(const Path & path)
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -70,8 +70,6 @@ public:
|
|||
|
||||
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
||||
|
||||
void registerMaybeStatePath(const Path & drvPath);
|
||||
|
||||
bool isStateComponent(const Path & path);
|
||||
|
||||
bool isStateDrv(const Path & drvpath);
|
||||
|
|
|
|||
|
|
@ -192,9 +192,6 @@ public:
|
|||
/* TODO */
|
||||
virtual vector<int> getStatePathsInterval(const PathSet & statePaths) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void registerMaybeStatePath(const Path & drvPath) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual bool isStateComponent(const Path & path) = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue