Compare commits
2 Commits
master
...
more-add-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
456b917535 | ||
|
|
f8095b793d |
@@ -296,8 +296,8 @@ void BinaryCacheStore::addToStore(
|
||||
const ValidPathInfo & info, Source & narSource, RepairFlag repair, CheckSigsFlag checkSigs)
|
||||
{
|
||||
if (!repair && isValidPath(info.path)) {
|
||||
// FIXME: copyNAR -> null sink
|
||||
narSource.drain();
|
||||
NullFileSystemObjectSink s;
|
||||
parseDump(s, narSource);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,8 +157,13 @@ struct DummyStoreImpl : DummyStore
|
||||
unsupported("queryPathFromHashPart");
|
||||
}
|
||||
|
||||
void addToStore(const ValidPathInfo & info, Source & source, RepairFlag repair, CheckSigsFlag checkSigs) override
|
||||
void
|
||||
addToStore(const ValidPathInfo & info, const SourcePath & path, RepairFlag repair, CheckSigsFlag checkSigs) override
|
||||
{
|
||||
if (!repair && isValidPath(info.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (config->readOnly)
|
||||
unsupported("addToStore");
|
||||
|
||||
@@ -168,19 +173,19 @@ struct DummyStoreImpl : DummyStore
|
||||
if (checkSigs)
|
||||
throw Error("checking signatures is not supported for '%s' store", config->getHumanReadableURI());
|
||||
|
||||
auto temp = make_ref<MemorySourceAccessor>();
|
||||
MemorySink tempSink{*temp};
|
||||
parseDump(tempSink, source);
|
||||
auto path = info.path;
|
||||
auto accessor = make_ref<MemorySourceAccessor>();
|
||||
{
|
||||
MemorySink tempSink{*accessor};
|
||||
copyRecursive(*path.accessor, path.path, tempSink, CanonPath::root);
|
||||
}
|
||||
|
||||
auto accessor = make_ref<MemorySourceAccessor>(std::move(*temp));
|
||||
contents.insert(
|
||||
{path,
|
||||
{info.path,
|
||||
PathInfoAndContents{
|
||||
std::move(info),
|
||||
info,
|
||||
accessor,
|
||||
}});
|
||||
wholeStoreView->addObject(path.to_string(), accessor);
|
||||
wholeStoreView->addObject(info.path.to_string(), accessor);
|
||||
}
|
||||
|
||||
StorePath addToStoreFromDump(
|
||||
|
||||
@@ -511,13 +511,28 @@ public:
|
||||
virtual void querySubstitutablePathInfos(const StorePathCAMap & paths, SubstitutablePathInfos & infos);
|
||||
|
||||
/**
|
||||
* Import a path into the store.
|
||||
* Import a path into the store, via NAR stream.
|
||||
*
|
||||
* One of these two must be overridden, as the defaults will
|
||||
* infinitely mutually recur.
|
||||
*/
|
||||
virtual void addToStore(
|
||||
const ValidPathInfo & info,
|
||||
Source & narSource,
|
||||
RepairFlag repair = NoRepair,
|
||||
CheckSigsFlag checkSigs = CheckSigs) = 0;
|
||||
CheckSigsFlag checkSigs = CheckSigs);
|
||||
|
||||
/**
|
||||
* Import a path into the store, via arbitrary `SourcePath`.
|
||||
*
|
||||
* One of these two must be overridden, as the defaults will
|
||||
* infinitely mutually recur.
|
||||
*/
|
||||
virtual void addToStore(
|
||||
const ValidPathInfo & info,
|
||||
const SourcePath & path,
|
||||
RepairFlag repair = NoRepair,
|
||||
CheckSigsFlag checkSigs = CheckSigs);
|
||||
|
||||
/**
|
||||
* A list of paths infos along with a source providing the content
|
||||
|
||||
@@ -145,6 +145,12 @@ void LegacySSHStore::queryPathInfoUncached(
|
||||
|
||||
void LegacySSHStore::addToStore(const ValidPathInfo & info, Source & source, RepairFlag repair, CheckSigsFlag checkSigs)
|
||||
{
|
||||
if (!repair && isValidPath(info.path)) {
|
||||
NullFileSystemObjectSink s;
|
||||
parseDump(s, source);
|
||||
return;
|
||||
}
|
||||
|
||||
debug("adding path '%s' to remote host '%s'", printStorePath(info.path), config->authority.host);
|
||||
|
||||
auto conn(connections->get());
|
||||
|
||||
@@ -424,6 +424,12 @@ StorePath RemoteStore::addToStoreFromDump(
|
||||
|
||||
void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, RepairFlag repair, CheckSigsFlag checkSigs)
|
||||
{
|
||||
if (!repair && isValidPath(info.path)) {
|
||||
NullFileSystemObjectSink s;
|
||||
parseDump(s, source);
|
||||
return;
|
||||
}
|
||||
|
||||
auto conn(getConnection());
|
||||
|
||||
conn->to << WorkerProto::Op::AddToStoreNar << printStorePath(info.path)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "nix/util/logging.hh"
|
||||
#include "nix/util/signature/local-keys.hh"
|
||||
#include "nix/util/source-accessor.hh"
|
||||
#include "nix/util/memory-source-accessor.hh"
|
||||
#include "nix/store/globals.hh"
|
||||
#include "nix/store/derived-path.hh"
|
||||
#include "nix/store/realisation.hh"
|
||||
@@ -84,6 +84,30 @@ StorePath Store::followLinksToStorePath(std::string_view path) const
|
||||
return toStorePath(followLinksToStore(path)).first;
|
||||
}
|
||||
|
||||
void Store::addToStore(const ValidPathInfo & info, Source & narSource, RepairFlag repair, CheckSigsFlag checkSigs)
|
||||
{
|
||||
if (!repair && isValidPath(info.path)) {
|
||||
NullFileSystemObjectSink s;
|
||||
parseDump(s, narSource);
|
||||
return;
|
||||
}
|
||||
|
||||
auto temp = make_ref<MemorySourceAccessor>();
|
||||
MemorySink tempSink{*temp};
|
||||
parseDump(tempSink, narSource);
|
||||
addToStore(info, {temp}, repair, checkSigs);
|
||||
}
|
||||
|
||||
void Store::addToStore(const ValidPathInfo & info, const SourcePath & path, RepairFlag repair, CheckSigsFlag checkSigs)
|
||||
{
|
||||
if (!repair && isValidPath(info.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto sink = sourceToSink([&](Source & source) { addToStore(info, source, repair, checkSigs); });
|
||||
dumpPath(path, *sink, FileSerialisationMethod::NixArchive);
|
||||
}
|
||||
|
||||
StorePath Store::addToStore(
|
||||
std::string_view name,
|
||||
const SourcePath & path,
|
||||
|
||||
Reference in New Issue
Block a user