aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-06-02 15:39:07 +0200
committerGitHub <noreply@github.com>2020-06-02 15:39:07 +0200
commitbfa1acd85c4d15c5ea95337138f47672659e2a9e (patch)
tree0baf08df6b477c4368861d439ceddf20fdb5fef6 /src/libstore
parentc16fdda3a6f647efe83faf874df3c1fee10c88bc (diff)
parentfac0c2d54a6b04175b40009506f2720d2594ed4e (diff)
Merge pull request #3639 from obsidiansystems/do-fixme-store-removes
Remove `addToStore` variant as requested by `FIXME`
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/binary-cache-store.cc11
-rw-r--r--src/libstore/binary-cache-store.hh2
-rw-r--r--src/libstore/export-import.cc5
-rw-r--r--src/libstore/store-api.cc15
-rw-r--r--src/libstore/store-api.hh7
5 files changed, 14 insertions, 26 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index f13736c58..357962007 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -113,9 +113,12 @@ void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
diskCache->upsertNarInfo(getUri(), hashPart, std::shared_ptr<NarInfo>(narInfo));
}
-void BinaryCacheStore::addToStore(const ValidPathInfo & info, const ref<std::string> & nar,
+void BinaryCacheStore::addToStore(const ValidPathInfo & info, Source & narSource,
RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr<FSAccessor> accessor)
{
+ // FIXME: See if we can use the original source to reduce memory usage.
+ auto nar = make_ref<std::string>(narSource.drain());
+
if (!repair && isValidPath(info.path)) return;
/* Verify that all references are valid. This may do some .narinfo
@@ -347,7 +350,8 @@ StorePath BinaryCacheStore::addToStore(const string & name, const Path & srcPath
ValidPathInfo info(makeFixedOutputPath(method, h, name));
- addToStore(info, sink.s, repair, CheckSigs, nullptr);
+ auto source = StringSource { *sink.s };
+ addToStore(info, source, repair, CheckSigs, nullptr);
return std::move(info.path);
}
@@ -361,7 +365,8 @@ StorePath BinaryCacheStore::addTextToStore(const string & name, const string & s
if (repair || !isValidPath(info.path)) {
StringSink sink;
dumpString(s, sink);
- addToStore(info, sink.s, repair, CheckSigs, nullptr);
+ auto source = StringSource { *sink.s };
+ addToStore(info, source, repair, CheckSigs, nullptr);
}
return std::move(info.path);
diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh
index 4ff5609ed..52ef8aa7a 100644
--- a/src/libstore/binary-cache-store.hh
+++ b/src/libstore/binary-cache-store.hh
@@ -74,7 +74,7 @@ public:
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
{ unsupported("queryPathFromHashPart"); }
- void addToStore(const ValidPathInfo & info, const ref<std::string> & nar,
+ void addToStore(const ValidPathInfo & info, Source & narSource,
RepairFlag repair, CheckSigsFlag checkSigs,
std::shared_ptr<FSAccessor> accessor) override;
diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc
index 4692d1a7b..f0d01a240 100644
--- a/src/libstore/export-import.cc
+++ b/src/libstore/export-import.cc
@@ -1,3 +1,4 @@
+#include "serialise.hh"
#include "store-api.hh"
#include "archive.hh"
#include "worker-protocol.hh"
@@ -100,7 +101,9 @@ StorePaths Store::importPaths(Source & source, std::shared_ptr<FSAccessor> acces
if (readInt(source) == 1)
readString(source);
- addToStore(info, tee.source.data, NoRepair, checkSigs, accessor);
+ // Can't use underlying source, which would have been exhausted
+ auto source = StringSource { *tee.source.data };
+ addToStore(info, source, NoRepair, checkSigs, accessor);
res.push_back(info.path.clone());
}
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index d479b86cb..095363d0c 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -840,21 +840,6 @@ std::string makeFixedOutputCA(FileIngestionMethod recursive, const Hash & hash)
}
-void Store::addToStore(const ValidPathInfo & info, Source & narSource,
- RepairFlag repair, CheckSigsFlag checkSigs,
- std::shared_ptr<FSAccessor> accessor)
-{
- addToStore(info, make_ref<std::string>(narSource.drain()), repair, checkSigs, accessor);
-}
-
-void Store::addToStore(const ValidPathInfo & info, const ref<std::string> & nar,
- RepairFlag repair, CheckSigsFlag checkSigs,
- std::shared_ptr<FSAccessor> accessor)
-{
- StringSource source(*nar);
- addToStore(info, source, repair, checkSigs, accessor);
-}
-
}
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 3def209a6..b1e25fc7d 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -450,12 +450,7 @@ public:
/* Import a path into the store. */
virtual void addToStore(const ValidPathInfo & info, Source & narSource,
RepairFlag repair = NoRepair, CheckSigsFlag checkSigs = CheckSigs,
- std::shared_ptr<FSAccessor> accessor = 0);
-
- // FIXME: remove
- virtual void addToStore(const ValidPathInfo & info, const ref<std::string> & nar,
- RepairFlag repair = NoRepair, CheckSigsFlag checkSigs = CheckSigs,
- std::shared_ptr<FSAccessor> accessor = 0);
+ std::shared_ptr<FSAccessor> accessor = 0) = 0;
/* Copy the contents of a path to the store and register the
validity the resulting path. The resulting path is returned.