realiseContext: Handle all context types

Avoids an assertion
This commit is contained in:
Shea Levy 2014-11-15 21:43:51 -05:00
parent 3d604ac88c
commit 2719627bbe

View file

@ -35,7 +35,7 @@ std::pair<string, string> decodeContext(const string & s)
size_t index = s.find("!", 1); size_t index = s.find("!", 1);
return std::pair<string, string>(string(s, index + 1), string(s, 1, index - 1)); return std::pair<string, string>(string(s, index + 1), string(s, 1, index - 1));
} else } else
return std::pair<string, string>(s, ""); return std::pair<string, string>(s.at(0) == '/' ? s: string(s, 1), "");
} }
@ -51,7 +51,7 @@ void realiseContext(const PathSet & context)
assert(isStorePath(ctx)); assert(isStorePath(ctx));
if (!store->isValidPath(ctx)) if (!store->isValidPath(ctx))
throw InvalidPathError(ctx); throw InvalidPathError(ctx);
if (isDerivation(ctx)) if (!decoded.second.empty() && isDerivation(ctx))
drvs.insert(decoded.first + "!" + decoded.second); drvs.insert(decoded.first + "!" + decoded.second);
} }
if (!drvs.empty()) { if (!drvs.empty()) {