mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Don't convert InputPaths to strings prematurely.
This commit is contained in:
parent
b3fd7db63f
commit
d6066c90f8
1 changed files with 9 additions and 7 deletions
|
@ -2,8 +2,10 @@
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "url-parts.hh"
|
#include "url-parts.hh"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace nix::flake {
|
namespace nix::flake {
|
||||||
|
@ -46,18 +48,18 @@ StorePath LockedNode::computeStorePath(Store & store) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static std::shared_ptr<Node> doFind(const ref<Node>& root, const InputPath & path, std::vector<std::string>& visited) {
|
static std::shared_ptr<Node> doFind(const ref<Node>& root, const InputPath & path, std::vector<InputPath>& visited) {
|
||||||
auto pos = root;
|
auto pos = root;
|
||||||
|
|
||||||
auto pathS = printInputPath(path);
|
auto found = std::find(visited.cbegin(), visited.cend(), path);
|
||||||
auto found = std::find(visited.cbegin(), visited.cend(), pathS);
|
|
||||||
|
|
||||||
if(found != visited.end()) {
|
if(found != visited.end()) {
|
||||||
std::vector cycle(found, visited.cend());
|
std::vector<std::string> cycle;
|
||||||
cycle.push_back(pathS);
|
std::transform(found, visited.cend(), std::back_inserter(cycle), printInputPath);
|
||||||
|
cycle.push_back(printInputPath(path));
|
||||||
throw Error("follow cycle detected: [%s]", concatStringsSep(" -> ", cycle));
|
throw Error("follow cycle detected: [%s]", concatStringsSep(" -> ", cycle));
|
||||||
}
|
}
|
||||||
visited.push_back(pathS);
|
visited.push_back(path);
|
||||||
|
|
||||||
for (auto & elem : path) {
|
for (auto & elem : path) {
|
||||||
if (auto i = get(pos->inputs, elem)) {
|
if (auto i = get(pos->inputs, elem)) {
|
||||||
|
@ -78,7 +80,7 @@ static std::shared_ptr<Node> doFind(const ref<Node>& root, const InputPath & pat
|
||||||
|
|
||||||
std::shared_ptr<Node> LockFile::findInput(const InputPath & path)
|
std::shared_ptr<Node> LockFile::findInput(const InputPath & path)
|
||||||
{
|
{
|
||||||
std::vector<std::string> visited;
|
std::vector<InputPath> visited;
|
||||||
return doFind(root, path, visited);
|
return doFind(root, path, visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue