aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-03-01 16:07:15 +0100
committerEelco Dolstra <edolstra@gmail.com>2017-03-01 16:07:15 +0100
commitf61f67ddee12a976a0a6a20652e7c545b49fa46c (patch)
treef31e33eaa184861271baa9e10c00e809b70ba3df /src/libstore
parent374908726b87f6cd137ea7d097fdcda57003594e (diff)
RemoteStore::addToStore(): Send NAR rather than string containing NAR
This allows the NAR to be streamed in the future (though we're not doing that yet).
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/export-import.cc23
-rw-r--r--src/libstore/legacy-ssh-store.cc4
-rw-r--r--src/libstore/remote-store.cc5
3 files changed, 6 insertions, 26 deletions
diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc
index e584ae538..531f010d9 100644
--- a/src/libstore/export-import.cc
+++ b/src/libstore/export-import.cc
@@ -61,27 +61,6 @@ void Store::exportPath(const Path & path, Sink & sink)
hashAndWriteSink << exportMagic << path << info->references << info->deriver << 0;
}
-struct TeeSource : Source
-{
- Source & readSource;
- ref<std::string> data;
- TeeSource(Source & readSource)
- : readSource(readSource)
- , data(make_ref<std::string>())
- {
- }
- size_t read(unsigned char * data, size_t len)
- {
- size_t n = readSource.read(data, len);
- this->data->append((char *) data, n);
- return n;
- }
-};
-
-struct NopSink : ParseSink
-{
-};
-
Paths Store::importPaths(Source & source, std::shared_ptr<FSAccessor> accessor, bool dontCheckSigs)
{
Paths res;
@@ -92,7 +71,7 @@ Paths Store::importPaths(Source & source, std::shared_ptr<FSAccessor> accessor,
/* Extract the NAR from the source. */
TeeSource tee(source);
- NopSink sink;
+ ParseSink sink;
parseDump(sink, tee);
uint32_t magic = readInt(source);
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index b20ff185f..031fcac95 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -169,9 +169,9 @@ struct LegacySSHStore : public Store
/* FIXME: inefficient. */
ParseSink parseSink; /* null sink; just parse the NAR */
- SavingSourceAdapter savedNAR(conn->from);
+ TeeSource savedNAR(conn->from);
parseDump(parseSink, savedNAR);
- sink(savedNAR.s);
+ sink(*savedNAR.data);
}
/* Unsupported methods. */
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 642825914..47413d573 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -378,8 +378,9 @@ void RemoteStore::addToStore(const ValidPathInfo & info, const ref<std::string>
conn->to << wopAddToStoreNar
<< info.path << info.deriver << printHash(info.narHash)
<< info.references << info.registrationTime << info.narSize
- << info.ultimate << info.sigs << info.ca << *nar << repair << dontCheckSigs;
- // FIXME: don't send nar as a string
+ << info.ultimate << info.sigs << info.ca
+ << repair << dontCheckSigs;
+ conn->to(*nar);
conn->processStderr();
}
}