* nix-env --dry-run: show the total size of the substituter

downloads.
This commit is contained in:
Eelco Dolstra 2008-08-04 12:29:04 +00:00
parent 03427e76f1
commit c4f98941ed
4 changed files with 15 additions and 5 deletions

View file

@ -565,7 +565,10 @@ bool LocalStore::querySubstitutablePathInfo(const Path & path,
Path p; getline(*run.from, p); Path p; getline(*run.from, p);
info.references.insert(p); info.references.insert(p);
} }
info.downloadSize = 0; getline(*run.from, s);
long long size;
if (!string2Int(s, size)) abort();
info.downloadSize = size;
return true; return true;
} }
} }

View file

@ -46,8 +46,11 @@ Path findOutput(const Derivation & drv, string id)
void queryMissing(const PathSet & targets, void queryMissing(const PathSet & targets,
PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown) PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
unsigned long long & downloadSize)
{ {
downloadSize = 0;
PathSet todo(targets.begin(), targets.end()), done; PathSet todo(targets.begin(), targets.end()), done;
while (!todo.empty()) { while (!todo.empty()) {
@ -86,6 +89,7 @@ void queryMissing(const PathSet & targets,
SubstitutablePathInfo info; SubstitutablePathInfo info;
if (store->querySubstitutablePathInfo(p, info)) { if (store->querySubstitutablePathInfo(p, info)) {
willSubstitute.insert(p); willSubstitute.insert(p);
downloadSize += info.downloadSize;
todo.insert(info.references.begin(), info.references.end()); todo.insert(info.references.begin(), info.references.end());
} else } else
unknown.insert(p); unknown.insert(p);

View file

@ -29,7 +29,8 @@ Path findOutput(const Derivation & drv, string id);
derivations that will be built, and the set of output paths that derivations that will be built, and the set of output paths that
will be substituted. */ will be substituted. */
void queryMissing(const PathSet & targets, void queryMissing(const PathSet & targets,
PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown); PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
unsigned long long & downloadSize);
} }

View file

@ -540,7 +540,8 @@ static void printMissing(EvalState & state, const DrvInfos & elems)
targets.insert(i->queryOutPath(state)); targets.insert(i->queryOutPath(state));
} }
queryMissing(targets, willBuild, willSubstitute, unknown); unsigned long long downloadSize;
queryMissing(targets, willBuild, willSubstitute, unknown, downloadSize);
if (!willBuild.empty()) { if (!willBuild.empty()) {
printMsg(lvlInfo, format("the following derivations will be built:")); printMsg(lvlInfo, format("the following derivations will be built:"));
@ -549,7 +550,8 @@ static void printMissing(EvalState & state, const DrvInfos & elems)
} }
if (!willSubstitute.empty()) { if (!willSubstitute.empty()) {
printMsg(lvlInfo, format("the following paths will be downloaded/copied:")); printMsg(lvlInfo, format("the following paths will be downloaded/copied (%.2f MiB):") %
(downloadSize / (1024.0 * 1024.0)));
foreach (PathSet::iterator, i, willSubstitute) foreach (PathSet::iterator, i, willSubstitute)
printMsg(lvlInfo, format(" %1%") % *i); printMsg(lvlInfo, format(" %1%") % *i);
} }