mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-07 18:57:19 +02:00
InputAccessor::fetchToStore(): Support arbitrary ingestion methods
This commit is contained in:
parent
d2c0051784
commit
12214fef09
4 changed files with 10 additions and 8 deletions
|
@ -2329,7 +2329,7 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
|
||||||
auto dstPath = i != srcToStore.end()
|
auto dstPath = i != srcToStore.end()
|
||||||
? i->second
|
? i->second
|
||||||
: [&]() {
|
: [&]() {
|
||||||
auto dstPath = path.fetchToStore(store, path.baseName(), nullptr, repair);
|
auto dstPath = path.fetchToStore(store, path.baseName(), FileIngestionMethod::Recursive, nullptr, repair);
|
||||||
allowPath(dstPath);
|
allowPath(dstPath);
|
||||||
srcToStore.insert_or_assign(path, dstPath);
|
srcToStore.insert_or_assign(path, dstPath);
|
||||||
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
|
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
|
||||||
|
|
|
@ -2233,10 +2233,7 @@ static void addPath(
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
|
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
|
||||||
// FIXME
|
auto dstPath = state.rootPath(CanonPath(path)).fetchToStore(state.store, name, method, &filter, state.repair);
|
||||||
if (method != FileIngestionMethod::Recursive)
|
|
||||||
throw Error("'recursive = false' is not implemented");
|
|
||||||
auto dstPath = state.rootPath(CanonPath(path)).fetchToStore(state.store, name, &filter, state.repair);
|
|
||||||
if (expectedHash && expectedStorePath != dstPath)
|
if (expectedHash && expectedStorePath != dstPath)
|
||||||
state.debugThrowLastTrace(Error("store path mismatch in (possibly filtered) path added from '%s'", path));
|
state.debugThrowLastTrace(Error("store path mismatch in (possibly filtered) path added from '%s'", path));
|
||||||
state.allowAndSetStorePathString(dstPath, v);
|
state.allowAndSetStorePathString(dstPath, v);
|
||||||
|
|
|
@ -96,6 +96,7 @@ StorePath InputAccessor::fetchToStore(
|
||||||
ref<Store> store,
|
ref<Store> store,
|
||||||
const CanonPath & path,
|
const CanonPath & path,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
|
FileIngestionMethod method,
|
||||||
PathFilter * filter,
|
PathFilter * filter,
|
||||||
RepairFlag repair)
|
RepairFlag repair)
|
||||||
{
|
{
|
||||||
|
@ -107,8 +108,8 @@ StorePath InputAccessor::fetchToStore(
|
||||||
|
|
||||||
auto storePath =
|
auto storePath =
|
||||||
settings.readOnlyMode
|
settings.readOnlyMode
|
||||||
? store->computeStorePathFromDump(*source, name).first
|
? store->computeStorePathFromDump(*source, name, method, htSHA256).first
|
||||||
: store->addToStoreFromDump(*source, name, FileIngestionMethod::Recursive, htSHA256, repair);
|
: store->addToStoreFromDump(*source, name, method, htSHA256, repair);
|
||||||
|
|
||||||
return storePath;
|
return storePath;
|
||||||
}
|
}
|
||||||
|
@ -140,10 +141,11 @@ std::ostream & operator << (std::ostream & str, const SourcePath & path)
|
||||||
StorePath SourcePath::fetchToStore(
|
StorePath SourcePath::fetchToStore(
|
||||||
ref<Store> store,
|
ref<Store> store,
|
||||||
std::string_view name,
|
std::string_view name,
|
||||||
|
FileIngestionMethod method,
|
||||||
PathFilter * filter,
|
PathFilter * filter,
|
||||||
RepairFlag repair) const
|
RepairFlag repair) const
|
||||||
{
|
{
|
||||||
return accessor->fetchToStore(store, path, name, filter, repair);
|
return accessor->fetchToStore(store, path, name, method, filter, repair);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view SourcePath::baseName() const
|
std::string_view SourcePath::baseName() const
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "canon-path.hh"
|
#include "canon-path.hh"
|
||||||
#include "repair-flag.hh"
|
#include "repair-flag.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
|
#include "content-address.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ struct InputAccessor : public std::enable_shared_from_this<InputAccessor>
|
||||||
ref<Store> store,
|
ref<Store> store,
|
||||||
const CanonPath & path,
|
const CanonPath & path,
|
||||||
std::string_view name = "source",
|
std::string_view name = "source",
|
||||||
|
FileIngestionMethod method = FileIngestionMethod::Recursive,
|
||||||
PathFilter * filter = nullptr,
|
PathFilter * filter = nullptr,
|
||||||
RepairFlag repair = NoRepair);
|
RepairFlag repair = NoRepair);
|
||||||
|
|
||||||
|
@ -181,6 +183,7 @@ struct SourcePath
|
||||||
StorePath fetchToStore(
|
StorePath fetchToStore(
|
||||||
ref<Store> store,
|
ref<Store> store,
|
||||||
std::string_view name = "source",
|
std::string_view name = "source",
|
||||||
|
FileIngestionMethod method = FileIngestionMethod::Recursive,
|
||||||
PathFilter * filter = nullptr,
|
PathFilter * filter = nullptr,
|
||||||
RepairFlag repair = NoRepair) const;
|
RepairFlag repair = NoRepair) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue