aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-11-16 17:11:46 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-11-16 17:11:46 +0000
commita3883cbd28057a3dd2573f77dcda9a26faaac555 (patch)
tree3ad605543e6bba8869f9413fb4f77f73e936cd1a /src/libstore/store-api.cc
parentfb9368b5a0b2457b28f19d4902bc0790123338a2 (diff)
* Store the size of a store path in the database (to be precise, the
size of the NAR serialisation of the path, i.e., `nix-store --dump PATH'). This is useful for Hydra.
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 01dd51621..4b04f5751 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -190,7 +190,7 @@ std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
bool recursive, HashType hashAlgo, PathFilter & filter)
{
HashType ht(hashAlgo);
- Hash h = recursive ? hashPath(ht, srcPath, filter) : hashFile(ht, srcPath);
+ Hash h = recursive ? hashPath(ht, srcPath, filter).first : hashFile(ht, srcPath);
string name = baseNameOf(srcPath);
Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name);
return std::pair<Path, Hash>(dstPath, h);
@@ -216,7 +216,7 @@ Path computeStorePathForText(const string & name, const string & s,
/* 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,
+string StoreAPI::makeValidityRegistration(const PathSet & paths,
bool showDerivers, bool showHash)
{
string s = "";
@@ -224,18 +224,19 @@ string makeValidityRegistration(const PathSet & paths,
foreach (PathSet::iterator, i, paths) {
s += *i + "\n";
- if (showHash)
- s += printHash(store->queryPathHash(*i)) + "\n";
+ ValidPathInfo info = queryPathInfo(*i);
- Path deriver = showDerivers ? store->queryDeriver(*i) : "";
+ if (showHash) {
+ s += printHash(info.hash) + "\n";
+ s += (format("%1%\n") % info.narSize).str();
+ }
+
+ Path deriver = showDerivers ? info.deriver : "";
s += deriver + "\n";
- PathSet references;
- store->queryReferences(*i, references);
+ s += (format("%1%\n") % info.references.size()).str();
- s += (format("%1%\n") % references.size()).str();
-
- foreach (PathSet::iterator, j, references)
+ foreach (PathSet::iterator, j, info.references)
s += *j + "\n";
}
@@ -252,6 +253,8 @@ ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven)
string s;
getline(str, s);
info.hash = parseHash(htSHA256, s);
+ getline(str, s);
+ if (!string2Int(s, info.narSize)) throw Error("number expected");
}
getline(str, info.deriver);
string s; int n;