diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-25T15·49+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-25T15·49+0200 |
commit | c137c0a5ebc0d58c53f86986ab66967ac8629cbe (patch) | |
tree | 38e01bef5549985449a4c911c1444758d585335f /src/libstore | |
parent | f194629f96d4bdbded897e7e88ac0d03211c959d (diff) |
Allow activities to be nested
In particular, this allows more relevant activities ("substituting X") to supersede inferior ones ("downloading X").
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build.cc | 9 | ||||
-rw-r--r-- | src/libstore/download.cc | 2 | ||||
-rw-r--r-- | src/libstore/download.hh | 4 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 4 |
4 files changed, 13 insertions, 6 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 77dee2914677..cb67d7a6c144 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -2407,14 +2407,14 @@ struct BuilderLogger : Logger } void startActivity(ActivityId act, ActivityType type, - const std::string & s, const Fields & fields) override + const std::string & s, const Fields & fields, ActivityId parent) override { nlohmann::json json; json["action"] = "start"; json["id"] = act; json["type"] = type; json["text"] = s; - // FIXME: handle fields + // FIXME: handle fields, parent log(lvlError, "@nix " + json.dump()); } @@ -3313,7 +3313,7 @@ void DerivationGoal::flushLine() if (type == actDownload) builderActivities.emplace(std::piecewise_construct, std::forward_as_tuple(json["id"]), - std::forward_as_tuple(*logger, type, json["text"])); + std::forward_as_tuple(*logger, type, json["text"], Logger::Fields{}, act->id)); } else if (action == "stop") @@ -3655,6 +3655,9 @@ void SubstitutionGoal::tryToRun() /* Wake up the worker loop when we're done. */ Finally updateStats([this]() { outPipe.writeSide = -1; }); + Activity act(*logger, actSubstitute, "", Logger::Fields{storePath, sub->getUri()}); + PushActivity pact(act.id); + copyStorePath(ref<Store>(sub), ref<Store>(worker.store.shared_from_this()), storePath, repair); diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 71b720a3b59e..a20999176778 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -85,7 +85,7 @@ struct CurlDownloader : public Downloader DownloadItem(CurlDownloader & downloader, const DownloadRequest & request) : downloader(downloader) , request(request) - , act(*logger, actDownload, fmt("downloading '%s'", request.uri)) + , act(*logger, actDownload, fmt("downloading '%s'", request.uri), {}, request.parentAct) { if (!request.expectedETag.empty()) requestHeaders = curl_slist_append(requestHeaders, ("If-None-Match: " + request.expectedETag).c_str()); diff --git a/src/libstore/download.hh b/src/libstore/download.hh index 7d8982d64c4c..752bf3723cfc 100644 --- a/src/libstore/download.hh +++ b/src/libstore/download.hh @@ -16,8 +16,10 @@ struct DownloadRequest bool head = false; size_t tries = 5; unsigned int baseRetryTimeMs = 250; + ActivityId parentAct; - DownloadRequest(const std::string & uri) : uri(uri) { } + DownloadRequest(const std::string & uri) + : uri(uri), parentAct(curActivity) { } }; struct DownloadResult diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index f520210615a3..f07376852711 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -565,7 +565,9 @@ void Store::buildPaths(const PathSet & paths, BuildMode buildMode) void copyStorePath(ref<Store> srcStore, ref<Store> dstStore, const Path & storePath, RepairFlag repair, CheckSigsFlag checkSigs) { - Activity act(*logger, actCopyPath, fmt("copying path '%s'", storePath)); + Activity act(*logger, actCopyPath, fmt("copying path '%s'", storePath), + {storePath, srcStore->getUri(), dstStore->getUri()}); + PushActivity pact(act.id); auto info = srcStore->queryPathInfo(storePath); |