forked from lix-project/lix
scanForReferences(): Use a StorePathSet
This commit is contained in:
parent
172b7f266c
commit
ef34fd0656
|
@ -2140,8 +2140,7 @@ void LocalDerivationGoal::registerOutputs()
|
||||||
|
|
||||||
/* Pass blank Sink as we are not ready to hash data at this stage. */
|
/* Pass blank Sink as we are not ready to hash data at this stage. */
|
||||||
NullSink blank;
|
NullSink blank;
|
||||||
auto references = worker.store.parseStorePathSet(
|
auto references = scanForReferences(blank, actualPath, referenceablePaths);
|
||||||
scanForReferences(blank, actualPath, worker.store.printStorePathSet(referenceablePaths)));
|
|
||||||
|
|
||||||
outputReferencesIfUnregistered.insert_or_assign(
|
outputReferencesIfUnregistered.insert_or_assign(
|
||||||
outputName,
|
outputName,
|
||||||
|
|
|
@ -72,43 +72,40 @@ struct RefScanSink : Sink
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::pair<PathSet, HashResult> scanForReferences(const string & path,
|
std::pair<StorePathSet, HashResult> scanForReferences(
|
||||||
const PathSet & refs)
|
const string & path,
|
||||||
|
const StorePathSet & refs)
|
||||||
{
|
{
|
||||||
HashSink hashSink { htSHA256 };
|
HashSink hashSink { htSHA256 };
|
||||||
auto found = scanForReferences(hashSink, path, refs);
|
auto found = scanForReferences(hashSink, path, refs);
|
||||||
auto hash = hashSink.finish();
|
auto hash = hashSink.finish();
|
||||||
return std::pair<PathSet, HashResult>(found, hash);
|
return std::pair<StorePathSet, HashResult>(found, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSet scanForReferences(Sink & toTee,
|
StorePathSet scanForReferences(
|
||||||
const string & path, const PathSet & refs)
|
Sink & toTee,
|
||||||
|
const Path & path,
|
||||||
|
const StorePathSet & refs)
|
||||||
{
|
{
|
||||||
RefScanSink refsSink;
|
RefScanSink refsSink;
|
||||||
TeeSink sink { refsSink, toTee };
|
TeeSink sink { refsSink, toTee };
|
||||||
std::map<string, Path> backMap;
|
std::map<std::string, StorePath> backMap;
|
||||||
|
|
||||||
for (auto & i : refs) {
|
for (auto & i : refs) {
|
||||||
auto baseName = std::string(baseNameOf(i));
|
std::string hashPart(i.hashPart());
|
||||||
string::size_type pos = baseName.find('-');
|
auto inserted = backMap.emplace(hashPart, i).second;
|
||||||
if (pos == string::npos)
|
assert(inserted);
|
||||||
throw Error("bad reference '%1%'", i);
|
refsSink.hashes.insert(hashPart);
|
||||||
string s = string(baseName, 0, pos);
|
|
||||||
assert(s.size() == refLength);
|
|
||||||
assert(backMap.find(s) == backMap.end());
|
|
||||||
// parseHash(htSHA256, s);
|
|
||||||
refsSink.hashes.insert(s);
|
|
||||||
backMap[s] = i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look for the hashes in the NAR dump of the path. */
|
/* Look for the hashes in the NAR dump of the path. */
|
||||||
dumpPath(path, sink);
|
dumpPath(path, sink);
|
||||||
|
|
||||||
/* Map the hashes found back to their store paths. */
|
/* Map the hashes found back to their store paths. */
|
||||||
PathSet found;
|
StorePathSet found;
|
||||||
for (auto & i : refsSink.seen) {
|
for (auto & i : refsSink.seen) {
|
||||||
std::map<string, Path>::iterator j;
|
auto j = backMap.find(i);
|
||||||
if ((j = backMap.find(i)) == backMap.end()) abort();
|
assert(j != backMap.end());
|
||||||
found.insert(j->second);
|
found.insert(j->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "types.hh"
|
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
|
#include "path.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
std::pair<PathSet, HashResult> scanForReferences(const Path & path, const PathSet & refs);
|
std::pair<StorePathSet, HashResult> scanForReferences(const Path & path, const StorePathSet & refs);
|
||||||
|
|
||||||
PathSet scanForReferences(Sink & toTee, const Path & path, const PathSet & refs);
|
StorePathSet scanForReferences(Sink & toTee, const Path & path, const StorePathSet & refs);
|
||||||
|
|
||||||
struct RewritingSink : Sink
|
struct RewritingSink : Sink
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue