mirror of
https://github.com/NixOS/nix.git
synced 2025-11-30 06:01:00 +01:00
State dirs/files to be versioned and state rights (user,grp,chmod) are now store in the db. Thuss we can remove their derivations at garbage collection time.
This commit is contained in:
parent
2d84c9e50c
commit
53e31381fa
9 changed files with 282 additions and 78 deletions
|
|
@ -158,6 +158,18 @@ static TableId dbStateSnapshots = 0;
|
|||
*/
|
||||
static TableId dbSharedState = 0;
|
||||
|
||||
/*
|
||||
* StatePath :: string
|
||||
* the string is converted to something of type StateInfos
|
||||
*/
|
||||
static TableId dbVersionItems = 0;
|
||||
|
||||
/*
|
||||
* StatePath :: string
|
||||
* the string contains the user,group and chmod
|
||||
*/
|
||||
static TableId dbStateRights = 0;
|
||||
|
||||
|
||||
static void upgradeStore07();
|
||||
static void upgradeStore09();
|
||||
|
|
@ -228,6 +240,8 @@ LocalStore::LocalStore(bool reserveSpace)
|
|||
dbStateSnapshots = nixDB.openTable("stateSnapshots");
|
||||
dbSharedState = nixDB.openTable("sharedState");
|
||||
dbSolidStateReferences = nixDB.openTable("references_solid_c_s"); /* The contents of this table is included in references_c_s */
|
||||
dbVersionItems = nixDB.openTable("stateItems");
|
||||
dbStateRights = nixDB.openTable("stateRights");
|
||||
|
||||
int curSchema = 0;
|
||||
Path schemaFN = nixDBPath + "/schema";
|
||||
|
|
@ -556,7 +570,7 @@ static PathSet getXReferrers(const Transaction & txn, const Path & store_or_stat
|
|||
for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i){
|
||||
Path getStatePath;
|
||||
unsigned int getRevision;
|
||||
splitDBKey(*i, getStatePath, getRevision);
|
||||
splitDBRevKey(*i, getStatePath, getRevision);
|
||||
|
||||
if(latest[getStatePath] == 0) //either it is unset
|
||||
latest[getStatePath] = getRevision;
|
||||
|
|
@ -575,7 +589,7 @@ static PathSet getXReferrers(const Transaction & txn, const Path & store_or_stat
|
|||
//printMsg(lvlError, format("AAAAA '%1%'") % (*i).first);
|
||||
|
||||
Strings references;
|
||||
nixDB.queryStrings(txn, table, mergeToDBKey((*i).first, (*i).second), references);
|
||||
nixDB.queryStrings(txn, table, mergeToDBRevKey((*i).first, (*i).second), references);
|
||||
for (Strings::iterator j = references.begin(); j != references.end(); ++j){
|
||||
//printMsg(lvlError, format("TEST: '%1%' has ref '%2%' check with '%3%'") % (*i).first % *j % path);
|
||||
if(*j == path)
|
||||
|
|
@ -1852,6 +1866,29 @@ void LocalStore::revertToRevision(const Path & statePath, const unsigned int rev
|
|||
txn.commit();
|
||||
}
|
||||
|
||||
void setVersionedStateEntriesTxn(const Transaction & txn, const Path & statePath,
|
||||
const StateInfos & infos, const unsigned int revision, const unsigned int timestamp)
|
||||
{
|
||||
setVersionedStateEntries(nixDB, txn, dbVersionItems, dbStateRevisions,
|
||||
statePath, infos, revision, timestamp);
|
||||
}
|
||||
|
||||
bool getVersionedStateEntriesTxn(const Transaction & txn, const Path & statePath,
|
||||
StateInfos & infos, const unsigned int revision, const unsigned int timestamp)
|
||||
{
|
||||
return getVersionedStateEntries(nixDB, txn, dbVersionItems, dbStateRevisions,
|
||||
statePath, infos, revision, timestamp);
|
||||
}
|
||||
|
||||
void setStateUserGroupTxn(const Transaction & txn, const Path & statePath, const string & user, const string & group, int chmod)
|
||||
{
|
||||
setStateUserGroup(nixDB, txn, dbStateRights, statePath, user, group, chmod);
|
||||
}
|
||||
|
||||
void getStateUserGroupTxn(const Transaction & txn, const Path & statePath, string & user, string & group, int & chmod)
|
||||
{
|
||||
getStateUserGroup(nixDB, txn, dbStateRights, statePath, user, group, chmod);
|
||||
}
|
||||
|
||||
typedef std::map<Hash, std::pair<Path, ino_t> > HashToPath;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue