forked from lix-project/lix
Coding style
This commit is contained in:
parent
c6b063c31a
commit
af94b54db3
|
@ -325,12 +325,23 @@ LockedFlake lockFlake(
|
||||||
|
|
||||||
std::vector<FlakeRef> parents;
|
std::vector<FlakeRef> parents;
|
||||||
|
|
||||||
|
struct LockParent {
|
||||||
|
/* The path to this parent. */
|
||||||
|
InputPath path;
|
||||||
|
|
||||||
|
/* Whether we are currently inside a top-level lockfile
|
||||||
|
(inputs absolute) or subordinate lockfile (inputs
|
||||||
|
relative). */
|
||||||
|
bool absolute;
|
||||||
|
};
|
||||||
|
|
||||||
std::function<void(
|
std::function<void(
|
||||||
const FlakeInputs & flakeInputs,
|
const FlakeInputs & flakeInputs,
|
||||||
std::shared_ptr<Node> node,
|
std::shared_ptr<Node> node,
|
||||||
const InputPath & inputPathPrefix,
|
const InputPath & inputPathPrefix,
|
||||||
std::shared_ptr<const Node> oldNode,
|
std::shared_ptr<const Node> oldNode,
|
||||||
const LockParent parent, const Path parentPath)>
|
const LockParent & parent,
|
||||||
|
const Path & parentPath)>
|
||||||
computeLocks;
|
computeLocks;
|
||||||
|
|
||||||
computeLocks = [&](
|
computeLocks = [&](
|
||||||
|
@ -338,7 +349,8 @@ LockedFlake lockFlake(
|
||||||
std::shared_ptr<Node> node,
|
std::shared_ptr<Node> node,
|
||||||
const InputPath & inputPathPrefix,
|
const InputPath & inputPathPrefix,
|
||||||
std::shared_ptr<const Node> oldNode,
|
std::shared_ptr<const Node> oldNode,
|
||||||
const LockParent parent, const Path parentPath)
|
const LockParent & parent,
|
||||||
|
const Path & parentPath)
|
||||||
{
|
{
|
||||||
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
|
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
|
||||||
|
|
||||||
|
@ -384,15 +396,11 @@ LockedFlake lockFlake(
|
||||||
if (parent.absolute && !hasOverride) {
|
if (parent.absolute && !hasOverride) {
|
||||||
target = *input.follows;
|
target = *input.follows;
|
||||||
} else {
|
} else {
|
||||||
if (hasOverride)
|
if (hasOverride) {
|
||||||
{
|
|
||||||
target = inputPathPrefix;
|
target = inputPathPrefix;
|
||||||
target.pop_back();
|
target.pop_back();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
|
||||||
target = parent.path;
|
target = parent.path;
|
||||||
}
|
|
||||||
|
|
||||||
for (auto & i : *input.follows) target.push_back(i);
|
for (auto & i : *input.follows) target.push_back(i);
|
||||||
}
|
}
|
||||||
|
@ -480,8 +488,7 @@ LockedFlake lockFlake(
|
||||||
|
|
||||||
// If this input is a path, recurse it down.
|
// If this input is a path, recurse it down.
|
||||||
// This allows us to resolve path inputs relative to the current flake.
|
// This allows us to resolve path inputs relative to the current flake.
|
||||||
if (localRef.input.getType() == "path")
|
if (localRef.input.getType() == "path") {
|
||||||
{
|
|
||||||
localRef.input.parent = parentPath;
|
localRef.input.parent = parentPath;
|
||||||
localPath = canonPath(parentPath + "/" + *input.ref->input.getSourcePath());
|
localPath = canonPath(parentPath + "/" + *input.ref->input.getSourcePath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,15 +124,6 @@ struct LockFlags
|
||||||
std::set<InputPath> inputUpdates;
|
std::set<InputPath> inputUpdates;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LockParent {
|
|
||||||
/* The path to this parent */
|
|
||||||
InputPath path;
|
|
||||||
|
|
||||||
/* Whether we are currently inside a top-level lockfile (inputs absolute)
|
|
||||||
or subordinate lockfile (inputs relative) */
|
|
||||||
bool absolute;
|
|
||||||
};
|
|
||||||
|
|
||||||
LockedFlake lockFlake(
|
LockedFlake lockFlake(
|
||||||
EvalState & state,
|
EvalState & state,
|
||||||
const FlakeRef & flakeRef,
|
const FlakeRef & flakeRef,
|
||||||
|
|
|
@ -85,8 +85,7 @@ struct PathInputScheme : InputScheme
|
||||||
std::string absPath;
|
std::string absPath;
|
||||||
auto path = getStrAttr(input.attrs, "path");
|
auto path = getStrAttr(input.attrs, "path");
|
||||||
|
|
||||||
if (path[0] != '/' && input.parent)
|
if (path[0] != '/' && input.parent) {
|
||||||
{
|
|
||||||
auto parent = canonPath(*input.parent);
|
auto parent = canonPath(*input.parent);
|
||||||
|
|
||||||
// the path isn't relative, prefix it
|
// the path isn't relative, prefix it
|
||||||
|
@ -95,11 +94,8 @@ struct PathInputScheme : InputScheme
|
||||||
// for security, ensure that if the parent is a store path, it's inside it
|
// for security, ensure that if the parent is a store path, it's inside it
|
||||||
if (!parent.rfind(store->storeDir, 0) && absPath.rfind(store->storeDir, 0))
|
if (!parent.rfind(store->storeDir, 0) && absPath.rfind(store->storeDir, 0))
|
||||||
throw BadStorePath("relative path '%s' points outside of its parent's store path %s, this is a security violation", path, parent);
|
throw BadStorePath("relative path '%s' points outside of its parent's store path %s, this is a security violation", path, parent);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
|
||||||
absPath = path;
|
absPath = path;
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: check whether access to 'path' is allowed.
|
// FIXME: check whether access to 'path' is allowed.
|
||||||
auto storePath = store->maybeParseStorePath(absPath);
|
auto storePath = store->maybeParseStorePath(absPath);
|
||||||
|
|
Loading…
Reference in a new issue