Skip to content

Commit fd73c1e

Browse files
committed
Add an activity for binary cache queries
1 parent c2154d4 commit fd73c1e

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/libstore/binary-cache-store.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ void BinaryCacheStore::queryPathInfoUncached(const Path & storePath,
313313
std::function<void(std::shared_ptr<ValidPathInfo>)> success,
314314
std::function<void(std::exception_ptr exc)> failure)
315315
{
316+
auto uri = getUri();
317+
auto act = std::make_shared<Activity>(*logger, lvlTalkative, actQueryPathInfo,
318+
fmt("querying info about '%s' on '%s'", storePath, uri), Logger::Fields{storePath, uri});
319+
PushActivity pact(act->id);
320+
316321
auto narInfoFile = narInfoFileFor(storePath);
317322

318323
getFile(narInfoFile,
@@ -323,6 +328,8 @@ void BinaryCacheStore::queryPathInfoUncached(const Path & storePath,
323328

324329
callSuccess(success, failure, (std::shared_ptr<ValidPathInfo>)
325330
std::make_shared<NarInfo>(*this, *data, narInfoFile));
331+
332+
(void) act; // force Activity into this lambda to ensure it stays alive
326333
},
327334
failure);
328335
}

src/libstore/download.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct CurlDownloader : public Downloader
8585
DownloadItem(CurlDownloader & downloader, const DownloadRequest & request)
8686
: downloader(downloader)
8787
, request(request)
88-
, act(*logger, lvlTalkative, actDownload, fmt("downloading '%s'", request.uri), {}, request.parentAct)
88+
, act(*logger, lvlTalkative, actDownload, fmt("downloading '%s'", request.uri), {request.uri}, request.parentAct)
8989
{
9090
if (!request.expectedETag.empty())
9191
requestHeaders = curl_slist_append(requestHeaders, ("If-None-Match: " + request.expectedETag).c_str());

src/libutil/logging.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typedef enum {
2424
actOptimiseStore = 106,
2525
actVerifyPaths = 107,
2626
actSubstitute = 108,
27+
actQueryPathInfo = 109,
2728
} ActivityType;
2829

2930
typedef enum {

src/nix/progress-bar.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ class ProgressBar : public Logger
138138
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
139139
const std::string & s, const Fields & fields, ActivityId parent) override
140140
{
141-
if (lvl <= verbosity && !s.empty())
142-
log(lvl, s + "...");
143-
144141
auto state(state_.lock());
145142

143+
if (lvl <= verbosity && !s.empty())
144+
log(*state, lvl, s + "...");
145+
146146
state->activities.emplace_back(ActInfo());
147147
auto i = std::prev(state->activities.end());
148148
i->s = s;
@@ -163,7 +163,13 @@ class ProgressBar : public Logger
163163
i->s = fmt("fetching " ANSI_BOLD "%s" ANSI_NORMAL " from %s", name, getS(fields, 1));
164164
}
165165

166+
if (type == actQueryPathInfo) {
167+
auto name = storePathToName(getS(fields, 0));
168+
i->s = fmt("querying about " ANSI_BOLD "%s" ANSI_NORMAL " on %s", name, getS(fields, 1));
169+
}
170+
166171
if ((type == actDownload && hasAncestor(*state, actCopyPath, parent))
172+
|| (type == actDownload && hasAncestor(*state, actQueryPathInfo, parent))
167173
|| (type == actCopyPath && hasAncestor(*state, actSubstitute, parent)))
168174
i->visible = false;
169175

@@ -189,6 +195,7 @@ class ProgressBar : public Logger
189195

190196
auto i = state->its.find(act);
191197
if (i != state->its.end()) {
198+
192199
auto & actByType = state->activitiesByType[i->second->type];
193200
actByType.done += i->second->done;
194201
actByType.failed += i->second->failed;

0 commit comments

Comments
 (0)