aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorCarlo Nucera <carlo.nucera@protonmail.com>2020-07-16 13:32:28 -0400
committerCarlo Nucera <carlo.nucera@protonmail.com>2020-07-16 13:32:28 -0400
commit048e916f6477acc7e57e1d85e832d3efb42ad3f6 (patch)
tree3261da4d301fc6bd9df375a8bab3a4a555dc6199 /src/libstore/local-store.cc
parent886c91dfcc462d157dc2ce5265800e98d1bc45dd (diff)
parent16c9f6762d082155b967710a5fd3a095937d76ba (diff)
Merge branch 'master' of github.com:NixOS/nix into optional-derivation-output-storepath
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index d1aca9790..d1a3b95c1 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -587,7 +587,7 @@ uint64_t LocalStore::addValidPath(State & state,
(concatStringsSep(" ", info.sigs), !info.sigs.empty())
(renderContentAddress(info.ca), (bool) info.ca)
.exec();
- uint64_t id = sqlite3_last_insert_rowid(state.db);
+ uint64_t id = state.db.getLastInsertedRowId();
/* If this is a derivation, then store the derivation outputs in
the database. This is useful for the garbage collector: it can
@@ -955,7 +955,7 @@ const PublicKeys & LocalStore::getPublicKeys()
void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
- RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr<FSAccessor> accessor)
+ RepairFlag repair, CheckSigsFlag checkSigs)
{
if (!info.narHash)
throw Error("cannot add path '%s' because it lacks a hash", printStorePath(info.path));
@@ -1090,13 +1090,16 @@ StorePath LocalStore::addToStore(const string & name, const Path & _srcPath,
{
Path srcPath(absPath(_srcPath));
+ if (method != FileIngestionMethod::Recursive)
+ return addToStoreFromDump(readFile(srcPath), name, method, hashAlgo, repair);
+
/* For computing the NAR hash. */
auto sha256Sink = std::make_unique<HashSink>(htSHA256);
/* For computing the store path. In recursive SHA-256 mode, this
is the same as the NAR hash, so no need to do it again. */
std::unique_ptr<HashSink> hashSink =
- method == FileIngestionMethod::Recursive && hashAlgo == htSHA256
+ hashAlgo == htSHA256
? nullptr
: std::make_unique<HashSink>(hashAlgo);
@@ -1129,10 +1132,7 @@ StorePath LocalStore::addToStore(const string & name, const Path & _srcPath,
if (!inMemory) sink(buf, len);
});
- if (method == FileIngestionMethod::Recursive)
- dumpPath(srcPath, sink2, filter);
- else
- readFile(srcPath, sink2);
+ dumpPath(srcPath, sink2, filter);
});
std::unique_ptr<AutoDelete> delTempDir;
@@ -1148,10 +1148,7 @@ StorePath LocalStore::addToStore(const string & name, const Path & _srcPath,
delTempDir = std::make_unique<AutoDelete>(tempDir);
tempPath = tempDir + "/x";
- if (method == FileIngestionMethod::Recursive)
- restorePath(tempPath, *source);
- else
- writeFile(tempPath, *source);
+ restorePath(tempPath, *source);
} catch (EndOfFile &) {
if (!inMemory) throw;
@@ -1184,10 +1181,7 @@ StorePath LocalStore::addToStore(const string & name, const Path & _srcPath,
if (inMemory) {
/* Restore from the NAR in memory. */
StringSource source(nar);
- if (method == FileIngestionMethod::Recursive)
- restorePath(realPath, source);
- else
- writeFile(realPath, source);
+ restorePath(realPath, source);
} else {
/* Move the temporary path we restored above. */
if (rename(tempPath.c_str(), realPath.c_str()))