mirror of
https://github.com/NixOS/nix
synced 2025-06-29 19:03:16 +02:00
Checkpoint
This commit is contained in:
parent
2d572a250f
commit
c56e17b718
17 changed files with 428 additions and 79 deletions
|
@ -450,6 +450,7 @@ EvalState::EvalState(
|
|||
, sPrefix(symbols.create("prefix"))
|
||||
, repair(NoRepair)
|
||||
, emptyBindings(0)
|
||||
, rootFS(makeFSInputAccessor(""))
|
||||
, store(store)
|
||||
, buildStore(buildStore ? buildStore : store)
|
||||
, regexCache(makeRegexCache())
|
||||
|
@ -527,6 +528,7 @@ void EvalState::allowAndSetStorePathString(const StorePath &storePath, Value & v
|
|||
v.mkString(path, PathSet({path}));
|
||||
}
|
||||
|
||||
#if 0
|
||||
Path EvalState::checkSourcePath(const Path & path_)
|
||||
{
|
||||
if (!allowedPaths) return path_;
|
||||
|
@ -572,6 +574,7 @@ Path EvalState::checkSourcePath(const Path & path_)
|
|||
|
||||
throw RestrictedPathError("access to canonical path '%1%' is forbidden in restricted mode", path);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void EvalState::checkURI(const std::string & uri)
|
||||
|
@ -593,12 +596,14 @@ void EvalState::checkURI(const std::string & uri)
|
|||
/* If the URI is a path, then check it against allowedPaths as
|
||||
well. */
|
||||
if (hasPrefix(uri, "/")) {
|
||||
checkSourcePath(uri);
|
||||
// FIXME: use rootPath
|
||||
//checkSourcePath(uri);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasPrefix(uri, "file://")) {
|
||||
checkSourcePath(std::string(uri, 7));
|
||||
// FIXME: use rootPath
|
||||
//checkSourcePath(std::string(uri, 7));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -970,17 +975,23 @@ Value * ExprPath::maybeThunk(EvalState & state, Env & env)
|
|||
}
|
||||
|
||||
|
||||
void EvalState::evalFile(const Path & path_, Value & v, bool mustBeTrivial)
|
||||
void EvalState::evalFile(const SourcePath & path_, Value & v, bool mustBeTrivial)
|
||||
{
|
||||
#if 0
|
||||
auto path = checkSourcePath(path_);
|
||||
#endif
|
||||
|
||||
auto path = packPath(path_);
|
||||
|
||||
// FIXME: use SourcePath as cache key
|
||||
FileEvalCache::iterator i;
|
||||
if ((i = fileEvalCache.find(path)) != fileEvalCache.end()) {
|
||||
v = i->second;
|
||||
return;
|
||||
}
|
||||
|
||||
Path resolvedPath = resolveExprPath(path);
|
||||
auto resolvedPath_ = resolveExprPath(path_);
|
||||
auto resolvedPath = packPath(resolvedPath_);
|
||||
if ((i = fileEvalCache.find(resolvedPath)) != fileEvalCache.end()) {
|
||||
v = i->second;
|
||||
return;
|
||||
|
@ -994,7 +1005,10 @@ void EvalState::evalFile(const Path & path_, Value & v, bool mustBeTrivial)
|
|||
e = j->second;
|
||||
|
||||
if (!e)
|
||||
e = parseExprFromFile(resolvedPath_);
|
||||
#if 0
|
||||
e = parseExprFromFile(checkSourcePath(resolvedPath));
|
||||
#endif
|
||||
|
||||
cacheFile(path, resolvedPath, e, v, mustBeTrivial);
|
||||
}
|
||||
|
@ -2045,9 +2059,19 @@ std::string EvalState::copyPathToStore(PathSet & context, const Path & path)
|
|||
if (i != srcToStore.end())
|
||||
dstPath = store->printStorePath(i->second);
|
||||
else {
|
||||
// FIXME: use SourcePath
|
||||
printError("COPY %s", path);
|
||||
auto path2 = unpackPath(path);
|
||||
#if 0
|
||||
auto p = settings.readOnlyMode
|
||||
? store->computeStorePathForPath(std::string(baseNameOf(path)), checkSourcePath(path)).first
|
||||
: store->addToStore(std::string(baseNameOf(path)), checkSourcePath(path), FileIngestionMethod::Recursive, htSHA256, defaultPathFilter, repair);
|
||||
? store->computeStorePathForPath(std::string(baseNameOf(path)), canonPath(path)).first
|
||||
: store->addToStore(std::string(baseNameOf(path)), canonPath(path), FileIngestionMethod::Recursive, htSHA256, defaultPathFilter, repair);
|
||||
#endif
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
path2.accessor->dumpPath(path2.path, sink);
|
||||
});
|
||||
// FIXME: readOnlyMode
|
||||
auto p = store->addToStoreFromDump(*source, std::string(baseNameOf(path)), FileIngestionMethod::Recursive, htSHA256, repair);
|
||||
dstPath = store->printStorePath(p);
|
||||
allowPath(p);
|
||||
srcToStore.insert_or_assign(path, std::move(p));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue