diff options
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 22a66ccabdb2..b5bc85e1823f 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -151,11 +151,47 @@ Path computeStorePathForText(const string & suffix, const string & s, } -ValidPathInfo decodeValidPathInfo(std::istream & str) +/* Return a string accepted by decodeValidPathInfo() that + registers the specified paths as valid. Note: it's the + responsibility of the caller to provide a closure. */ +string makeValidityRegistration(const PathSet & paths, + bool showDerivers, bool showHash) +{ + string s = ""; + + for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) { + s += *i + "\n"; + + if (showHash) + s += printHash(store->queryPathHash(*i)) + "\n"; + + Path deriver = showDerivers ? store->queryDeriver(*i) : ""; + s += deriver + "\n"; + + PathSet references; + store->queryReferences(*i, references); + + s += (format("%1%\n") % references.size()).str(); + + for (PathSet::iterator j = references.begin(); + j != references.end(); ++j) + s += *j + "\n"; + } + + return s; +} + + +ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven) { ValidPathInfo info; getline(str, info.path); if (str.eof()) { info.path = ""; return info; } + if (hashGiven) { + string s; + getline(str, s); + info.hash = parseHash(htSHA256, s); + } getline(str, info.deriver); string s; int n; getline(str, s); |