Add an activity for binary cache queries
This commit is contained in:
parent
c2154d4c84
commit
fd73c1e20a
4 changed files with 19 additions and 4 deletions
|
@ -313,6 +313,11 @@ void BinaryCacheStore::queryPathInfoUncached(const Path & storePath,
|
||||||
std::function<void(std::shared_ptr<ValidPathInfo>)> success,
|
std::function<void(std::shared_ptr<ValidPathInfo>)> success,
|
||||||
std::function<void(std::exception_ptr exc)> failure)
|
std::function<void(std::exception_ptr exc)> failure)
|
||||||
{
|
{
|
||||||
|
auto uri = getUri();
|
||||||
|
auto act = std::make_shared<Activity>(*logger, lvlTalkative, actQueryPathInfo,
|
||||||
|
fmt("querying info about '%s' on '%s'", storePath, uri), Logger::Fields{storePath, uri});
|
||||||
|
PushActivity pact(act->id);
|
||||||
|
|
||||||
auto narInfoFile = narInfoFileFor(storePath);
|
auto narInfoFile = narInfoFileFor(storePath);
|
||||||
|
|
||||||
getFile(narInfoFile,
|
getFile(narInfoFile,
|
||||||
|
@ -323,6 +328,8 @@ void BinaryCacheStore::queryPathInfoUncached(const Path & storePath,
|
||||||
|
|
||||||
callSuccess(success, failure, (std::shared_ptr<ValidPathInfo>)
|
callSuccess(success, failure, (std::shared_ptr<ValidPathInfo>)
|
||||||
std::make_shared<NarInfo>(*this, *data, narInfoFile));
|
std::make_shared<NarInfo>(*this, *data, narInfoFile));
|
||||||
|
|
||||||
|
(void) act; // force Activity into this lambda to ensure it stays alive
|
||||||
},
|
},
|
||||||
failure);
|
failure);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct CurlDownloader : public Downloader
|
||||||
DownloadItem(CurlDownloader & downloader, const DownloadRequest & request)
|
DownloadItem(CurlDownloader & downloader, const DownloadRequest & request)
|
||||||
: downloader(downloader)
|
: downloader(downloader)
|
||||||
, request(request)
|
, request(request)
|
||||||
, act(*logger, lvlTalkative, actDownload, fmt("downloading '%s'", request.uri), {}, request.parentAct)
|
, act(*logger, lvlTalkative, actDownload, fmt("downloading '%s'", request.uri), {request.uri}, request.parentAct)
|
||||||
{
|
{
|
||||||
if (!request.expectedETag.empty())
|
if (!request.expectedETag.empty())
|
||||||
requestHeaders = curl_slist_append(requestHeaders, ("If-None-Match: " + request.expectedETag).c_str());
|
requestHeaders = curl_slist_append(requestHeaders, ("If-None-Match: " + request.expectedETag).c_str());
|
||||||
|
|
|
@ -24,6 +24,7 @@ typedef enum {
|
||||||
actOptimiseStore = 106,
|
actOptimiseStore = 106,
|
||||||
actVerifyPaths = 107,
|
actVerifyPaths = 107,
|
||||||
actSubstitute = 108,
|
actSubstitute = 108,
|
||||||
|
actQueryPathInfo = 109,
|
||||||
} ActivityType;
|
} ActivityType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -138,11 +138,11 @@ public:
|
||||||
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
||||||
const std::string & s, const Fields & fields, ActivityId parent) override
|
const std::string & s, const Fields & fields, ActivityId parent) override
|
||||||
{
|
{
|
||||||
if (lvl <= verbosity && !s.empty())
|
|
||||||
log(lvl, s + "...");
|
|
||||||
|
|
||||||
auto state(state_.lock());
|
auto state(state_.lock());
|
||||||
|
|
||||||
|
if (lvl <= verbosity && !s.empty())
|
||||||
|
log(*state, lvl, s + "...");
|
||||||
|
|
||||||
state->activities.emplace_back(ActInfo());
|
state->activities.emplace_back(ActInfo());
|
||||||
auto i = std::prev(state->activities.end());
|
auto i = std::prev(state->activities.end());
|
||||||
i->s = s;
|
i->s = s;
|
||||||
|
@ -163,7 +163,13 @@ public:
|
||||||
i->s = fmt("fetching " ANSI_BOLD "%s" ANSI_NORMAL " from %s", name, getS(fields, 1));
|
i->s = fmt("fetching " ANSI_BOLD "%s" ANSI_NORMAL " from %s", name, getS(fields, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == actQueryPathInfo) {
|
||||||
|
auto name = storePathToName(getS(fields, 0));
|
||||||
|
i->s = fmt("querying about " ANSI_BOLD "%s" ANSI_NORMAL " on %s", name, getS(fields, 1));
|
||||||
|
}
|
||||||
|
|
||||||
if ((type == actDownload && hasAncestor(*state, actCopyPath, parent))
|
if ((type == actDownload && hasAncestor(*state, actCopyPath, parent))
|
||||||
|
|| (type == actDownload && hasAncestor(*state, actQueryPathInfo, parent))
|
||||||
|| (type == actCopyPath && hasAncestor(*state, actSubstitute, parent)))
|
|| (type == actCopyPath && hasAncestor(*state, actSubstitute, parent)))
|
||||||
i->visible = false;
|
i->visible = false;
|
||||||
|
|
||||||
|
@ -189,6 +195,7 @@ public:
|
||||||
|
|
||||||
auto i = state->its.find(act);
|
auto i = state->its.find(act);
|
||||||
if (i != state->its.end()) {
|
if (i != state->its.end()) {
|
||||||
|
|
||||||
auto & actByType = state->activitiesByType[i->second->type];
|
auto & actByType = state->activitiesByType[i->second->type];
|
||||||
actByType.done += i->second->done;
|
actByType.done += i->second->done;
|
||||||
actByType.failed += i->second->failed;
|
actByType.failed += i->second->failed;
|
||||||
|
|
Loading…
Reference in a new issue