* Bug fix in path invalidation.
* More consistency checks.
This commit is contained in:
parent
60e86b124f
commit
c9cb1fa21f
|
@ -243,6 +243,16 @@ bool isValidPath(const Path & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void setOrClearStrings(Transaction & txn,
|
||||||
|
TableId table, const string & key, const Strings & value)
|
||||||
|
{
|
||||||
|
if (value.size() > 0)
|
||||||
|
nixDB.setStrings(txn, table, key, value);
|
||||||
|
else
|
||||||
|
nixDB.delPair(txn, table, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void invalidatePath(const Path & path, Transaction & txn)
|
static void invalidatePath(const Path & path, Transaction & txn)
|
||||||
{
|
{
|
||||||
debug(format("unregistering path `%1%'") % path);
|
debug(format("unregistering path `%1%'") % path);
|
||||||
|
@ -263,11 +273,10 @@ static void invalidatePath(const Path & path, Transaction & txn)
|
||||||
for (Paths::iterator i = revs.begin(); i != revs.end(); ++i) {
|
for (Paths::iterator i = revs.begin(); i != revs.end(); ++i) {
|
||||||
Paths subs;
|
Paths subs;
|
||||||
nixDB.queryStrings(txn, dbSubstitutes, *i, subs);
|
nixDB.queryStrings(txn, dbSubstitutes, *i, subs);
|
||||||
remove(subs.begin(), subs.end(), path);
|
if (find(subs.begin(), subs.end(), path) == subs.end())
|
||||||
if (subs.size() > 0)
|
throw Error("integrity error in substitutes mapping");
|
||||||
nixDB.setStrings(txn, dbSubstitutes, *i, subs);
|
subs.remove(path);
|
||||||
else
|
setOrClearStrings(txn, dbSubstitutes, *i, subs);
|
||||||
nixDB.delPair(txn, dbSubstitutes, *i);
|
|
||||||
}
|
}
|
||||||
nixDB.delPair(txn, dbSubstitutesRev, path);
|
nixDB.delPair(txn, dbSubstitutesRev, path);
|
||||||
}
|
}
|
||||||
|
@ -368,6 +377,8 @@ void verifyStore()
|
||||||
validPaths.insert(path);
|
validPaths.insert(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check that the values of the successor mappings are valid
|
||||||
|
paths. */
|
||||||
Paths sucs;
|
Paths sucs;
|
||||||
nixDB.enumTable(txn, dbSuccessors, sucs);
|
nixDB.enumTable(txn, dbSuccessors, sucs);
|
||||||
for (Paths::iterator i = sucs.begin(); i != sucs.end(); ++i) {
|
for (Paths::iterator i = sucs.begin(); i != sucs.end(); ++i) {
|
||||||
|
@ -382,6 +393,8 @@ void verifyStore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check that the keys of the reverse successor mappings are valid
|
||||||
|
paths. */
|
||||||
Paths rsucs;
|
Paths rsucs;
|
||||||
nixDB.enumTable(txn, dbSuccessorsRev, rsucs);
|
nixDB.enumTable(txn, dbSuccessorsRev, rsucs);
|
||||||
for (Paths::iterator i = rsucs.begin(); i != rsucs.end(); ++i) {
|
for (Paths::iterator i = rsucs.begin(); i != rsucs.end(); ++i) {
|
||||||
|
@ -391,27 +404,32 @@ void verifyStore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
/* Check that the values of the substitute mappings are valid
|
||||||
Paths sucs;
|
paths. */
|
||||||
nixDB.enumTable(txn, dbSuccessors, sucs);
|
Paths subs;
|
||||||
|
nixDB.enumTable(txn, dbSubstitutes, subs);
|
||||||
|
for (Paths::iterator i = subs.begin(); i != subs.end(); ++i) {
|
||||||
|
Paths subPaths, subPaths2;
|
||||||
|
nixDB.queryStrings(txn, dbSubstitutes, *i, subPaths);
|
||||||
|
for (Paths::iterator j = subPaths.begin(); j != subPaths.end(); ++j)
|
||||||
|
if (validPaths.find(*j) == validPaths.end())
|
||||||
|
debug(format("found substitute mapping to non-existent path `%1%'") % *j);
|
||||||
|
else
|
||||||
|
subPaths2.push_back(*j);
|
||||||
|
if (subPaths.size() != subPaths2.size())
|
||||||
|
setOrClearStrings(txn, dbSubstitutes, *i, subPaths2);
|
||||||
|
}
|
||||||
|
|
||||||
for (Paths::iterator i = sucs.begin(); i != sucs.end(); i++) {
|
/* Check that the keys of the reverse substitute mappings are
|
||||||
Path srcPath = *i;
|
valid paths. */
|
||||||
|
Paths rsubs;
|
||||||
Path sucPath;
|
nixDB.enumTable(txn, dbSubstitutesRev, rsubs);
|
||||||
if (!nixDB.queryString(txn, dbSuccessors, srcPath, sucPath)) abort();
|
for (Paths::iterator i = rsubs.begin(); i != rsubs.end(); ++i) {
|
||||||
|
if (validPaths.find(*i) == validPaths.end()) {
|
||||||
Paths revs;
|
debug(format("found reverse substitute mapping for non-existent path `%1%'") % *i);
|
||||||
nixDB.queryStrings(txn, dbSuccessorsRev, sucPath, revs);
|
nixDB.delPair(txn, dbSubstitutesRev, *i);
|
||||||
|
|
||||||
if (find(revs.begin(), revs.end(), srcPath) == revs.end()) {
|
|
||||||
debug(format("reverse successor mapping from `%1%' to `%2%' missing")
|
|
||||||
% srcPath % sucPath);
|
|
||||||
revs.push_back(srcPath);
|
|
||||||
nixDB.setStrings(txn, dbSuccessorsRev, sucPath, revs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue