diff options
author | Ben Burdette <bburdette@gmail.com> | 2020-05-29 09:51:37 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@gmail.com> | 2020-05-29 09:51:37 -0600 |
commit | 734283d636318b6dfc249afe1ddbb20bb4d02ed4 (patch) | |
tree | 1528b42a7c0017b674caec2deccaaa99ca9b856d /src/libstore/daemon.cc | |
parent | 92123c6c798682f3a7c1f19984dcd3a06ad6be92 (diff) | |
parent | f60ce4fa207a210e23a1142d3a8ead611526e6e1 (diff) |
Merge remote-tracking branch 'upstream/master' into errors-phase-2
Diffstat (limited to 'src/libstore/daemon.cc')
-rw-r--r-- | src/libstore/daemon.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index f8b449e5e..4fb7ed5b2 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -367,20 +367,24 @@ static void performOp(TunnelLogger * logger, ref<Store> store, } case wopAddToStore: { - bool fixed, recursive; std::string s, baseName; - from >> baseName >> fixed /* obsolete */ >> recursive >> s; - /* Compatibility hack. */ - if (!fixed) { - s = "sha256"; - recursive = true; + FileIngestionMethod method; + { + bool fixed, recursive; + from >> baseName >> fixed /* obsolete */ >> recursive >> s; + method = FileIngestionMethod { recursive }; + /* Compatibility hack. */ + if (!fixed) { + s = "sha256"; + method = FileIngestionMethod::Recursive; + } } HashType hashAlgo = parseHashType(s); TeeSource savedNAR(from); RetrieveRegularNARSink savedRegular; - if (recursive) { + if (method == FileIngestionMethod::Recursive) { /* Get the entire NAR dump from the client and save it to a string so that we can pass it to addToStoreFromDump(). */ @@ -392,7 +396,11 @@ static void performOp(TunnelLogger * logger, ref<Store> store, logger->startWork(); if (!savedRegular.regular) throw Error("regular file expected"); - auto path = store->addToStoreFromDump(recursive ? *savedNAR.data : savedRegular.s, baseName, recursive, hashAlgo); + auto path = store->addToStoreFromDump( + method == FileIngestionMethod::Recursive ? *savedNAR.data : savedRegular.s, + baseName, + method, + hashAlgo); logger->stopWork(); to << store->printStorePath(path); |