aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/daemon.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/daemon.cc')
-rw-r--r--src/libstore/daemon.cc51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc
index 8e9f9d71b..e370e278c 100644
--- a/src/libstore/daemon.cc
+++ b/src/libstore/daemon.cc
@@ -73,6 +73,18 @@ struct TunnelLogger : public Logger
enqueueMsg(*buf.s);
}
+ void logEI(const ErrorInfo & ei) override
+ {
+ if (ei.level > verbosity) return;
+
+ std::stringstream oss;
+ oss << ei;
+
+ StringSink buf;
+ buf << STDERR_NEXT << oss.str() << "\n"; // (fs.s + "\n");
+ enqueueMsg(*buf.s);
+ }
+
/* startWork() means that we're starting an operation for which we
want to send out stderr to the client. */
void startWork()
@@ -281,7 +293,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
auto path = store->parseStorePath(readString(from));
logger->startWork();
StorePathSet paths; // FIXME
- paths.insert(path.clone());
+ paths.insert(path);
auto res = store->querySubstitutablePaths(paths);
logger->stopWork();
to << (res.count(path) != 0);
@@ -315,7 +327,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
StorePathSet paths;
if (op == wopQueryReferences)
for (auto & i : store->queryPathInfo(path)->references)
- paths.insert(i.clone());
+ paths.insert(i);
else if (op == wopQueryReferrers)
store->queryReferrers(path, paths);
else if (op == wopQueryValidDerivers)
@@ -329,8 +341,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
case wopQueryDerivationOutputNames: {
auto path = store->parseStorePath(readString(from));
logger->startWork();
- StringSet names;
- names = store->queryDerivationOutputNames(path);
+ auto names = store->readDerivation(path).outputNames();
logger->stopWork();
to << names;
break;
@@ -355,20 +366,26 @@ 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; uint8_t recursive;
+ from >> baseName >> fixed /* obsolete */ >> recursive >> s;
+ if (recursive > (uint8_t) FileIngestionMethod::Recursive)
+ throw Error("unsupported FileIngestionMethod with value of %i; you may need to upgrade nix-daemon", recursive);
+ 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(). */
@@ -380,7 +397,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);
@@ -572,9 +593,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
auto path = store->parseStorePath(readString(from));
logger->startWork();
SubstitutablePathInfos infos;
- StorePathSet paths;
- paths.insert(path.clone()); // FIXME
- store->querySubstitutablePathInfos(paths, infos);
+ store->querySubstitutablePathInfos({path}, infos);
logger->stopWork();
auto i = infos.find(path);
if (i == infos.end())
@@ -735,7 +754,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
}
default:
- throw Error(format("invalid operation %1%") % op);
+ throw Error("invalid operation %1%", op);
}
}