diff options
Diffstat (limited to 'src/libstore/misc.cc')
-rw-r--r-- | src/libstore/misc.cc | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index e68edb38c..128c3c987 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -108,6 +108,31 @@ void Store::computeFSClosure(const StorePath & startPath, } +std::optional<std::string> getDerivationCA(const BasicDerivation & drv) +{ + auto outputHashMode = drv.env.find("outputHashMode"); + auto outputHash = drv.env.find("outputHash"); + + std::optional<HashType> ht = std::nullopt; + auto outputHashAlgo = drv.env.find("outputHashAlgo"); + if (outputHashAlgo != drv.env.end()) + ht = parseHashTypeOpt(outputHashAlgo->second); + + if (outputHashMode != drv.env.end() && outputHash != drv.env.end()) { + auto h = Hash(outputHash->second, ht); + FileIngestionMethod ingestionMethod; + if (outputHashMode->second == "recursive") + ingestionMethod = FileIngestionMethod::Recursive; + else if (outputHashMode->second == "flat") + ingestionMethod = FileIngestionMethod::Flat; + else + throw Error("unknown ingestion method: '%s'", outputHashMode->second); + return makeFixedOutputCA(ingestionMethod, h); + } + + return std::nullopt; +} + void Store::queryMissing(const std::vector<StorePathWithOutputs> & targets, StorePathSet & willBuild_, StorePathSet & willSubstitute_, StorePathSet & unknown_, unsigned long long & downloadSize_, unsigned long long & narSize_) @@ -157,7 +182,7 @@ void Store::queryMissing(const std::vector<StorePathWithOutputs> & targets, auto outPath = parseStorePath(outPathS); SubstitutablePathInfos infos; - querySubstitutablePathInfos({outPath}, infos); + querySubstitutablePathInfos({{outPath, getDerivationCA(*drv)}}, infos); if (infos.empty()) { drvState_->lock()->done = true; @@ -214,7 +239,7 @@ void Store::queryMissing(const std::vector<StorePathWithOutputs> & targets, if (isValidPath(path.path)) return; SubstitutablePathInfos infos; - querySubstitutablePathInfos({path.path}, infos); + querySubstitutablePathInfos({{path.path, std::nullopt}}, infos); if (infos.empty()) { auto state(state_.lock()); |