about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-03-01T15·07+0100
committerEelco Dolstra <edolstra@gmail.com>2017-03-01T15·07+0100
commitf61f67ddee12a976a0a6a20652e7c545b49fa46c (patch)
treef31e33eaa184861271baa9e10c00e809b70ba3df /src/libutil
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/libutil')
-rw-r--r--src/libutil/serialise.hh9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index 3072f422ea93..2bdee70807be 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -140,15 +140,16 @@ struct StringSource : Source
 
 
 /* Adapter class of a Source that saves all data read to `s'. */
-struct SavingSourceAdapter : Source
+struct TeeSource : Source
 {
     Source & orig;
-    string s;
-    SavingSourceAdapter(Source & orig) : orig(orig) { }
+    ref<std::string> data;
+    TeeSource(Source & orig)
+        : orig(orig), data(make_ref<std::string>()) { }
     size_t read(unsigned char * data, size_t len)
     {
         size_t n = orig.read(data, len);
-        s.append((const char *) data, n);
+        this->data->append((const char *) data, n);
         return n;
     }
 };