mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
Store::addToStore bail out on no-op earlier in many cases
`BinaryCacheStore` and `LocalStore` already had this optimization. Now, all the implementations do.
This commit is contained in:
parent
f8095b793d
commit
456b917535
5 changed files with 28 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,6 +160,10 @@ struct DummyStoreImpl : DummyStore
|
|||
void
|
||||
addToStore(const ValidPathInfo & info, const SourcePath & path, RepairFlag repair, CheckSigsFlag checkSigs) override
|
||||
{
|
||||
if (!repair && isValidPath(info.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (config->readOnly)
|
||||
unsupported("addToStore");
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,12 @@ StorePath Store::followLinksToStorePath(std::string_view path) const
|
|||
|
||||
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);
|
||||
|
|
@ -94,6 +100,10 @@ void Store::addToStore(const ValidPathInfo & info, Source & narSource, RepairFla
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue