diff options
Diffstat (limited to 'src/libstore/store.cc')
-rw-r--r-- | src/libstore/store.cc | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc index 9677f8422313..44b3a29e34d9 100644 --- a/src/libstore/store.cc +++ b/src/libstore/store.cc @@ -237,6 +237,30 @@ void registerSuccessor(const Transaction & txn, } +void unregisterSuccessor(const Path & srcPath) +{ + assertStorePath(srcPath); + + Transaction txn(nixDB); + + Path sucPath; + if (!nixDB.queryString(txn, dbSuccessors, srcPath, sucPath)) { + txn.abort(); + return; + } + nixDB.delPair(txn, dbSuccessors, srcPath); + + Paths revs; + nixDB.queryStrings(txn, dbSuccessorsRev, sucPath, revs); + Paths::iterator i = find(revs.begin(), revs.end(), srcPath); + assert(i != revs.end()); + revs.erase(i); + nixDB.setStrings(txn, dbSuccessorsRev, sucPath, revs); + + txn.commit(); +} + + bool querySuccessor(const Path & srcPath, Path & sucPath) { return nixDB.queryString(noTxn, dbSuccessors, srcPath, sucPath); @@ -294,10 +318,7 @@ static void writeSubstitutes(const Transaction & txn, ss.push_back(packStrings(ss2)); } - if (ss.size() == 0) - nixDB.delPair(txn, dbSubstitutes, srcPath); - else - nixDB.setStrings(txn, dbSubstitutes, srcPath, ss); + nixDB.setStrings(txn, dbSubstitutes, srcPath, ss); } |