about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-08-04T12·29+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-08-04T12·29+0000
commitc4f98941ed7e5e07786d92fc0be4435878f9b3cd (patch)
tree55d95e84f9ac65711144dd9456f71b0acc516ef8 /src
parent03427e76f11fe1d918020d28bdb69b2fb348ee96 (diff)
* nix-env --dry-run: show the total size of the substituter
  downloads.

Diffstat (limited to 'src')
-rw-r--r--src/libstore/local-store.cc5
-rw-r--r--src/libstore/misc.cc6
-rw-r--r--src/libstore/misc.hh3
-rw-r--r--src/nix-env/nix-env.cc6
4 files changed, 15 insertions, 5 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 6926c49370d8..141c7a85297f 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -565,7 +565,10 @@ bool LocalStore::querySubstitutablePathInfo(const Path & path,
                 Path p; getline(*run.from, 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;
         }
     }
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index 1759f521cc29..85197adcf0db 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -46,8 +46,11 @@ Path findOutput(const Derivation & drv, string id)
 
 
 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;
 
     while (!todo.empty()) {
@@ -86,6 +89,7 @@ void queryMissing(const PathSet & targets,
             SubstitutablePathInfo info;
             if (store->querySubstitutablePathInfo(p, info)) {
                 willSubstitute.insert(p);
+                downloadSize += info.downloadSize;
                 todo.insert(info.references.begin(), info.references.end());
             } else
                 unknown.insert(p);
diff --git a/src/libstore/misc.hh b/src/libstore/misc.hh
index 33d81ed4a07f..f3aa34076c19 100644
--- a/src/libstore/misc.hh
+++ b/src/libstore/misc.hh
@@ -29,7 +29,8 @@ Path findOutput(const Derivation & drv, string id);
    derivations that will be built, and the set of output paths that
    will be substituted. */
 void queryMissing(const PathSet & targets,
-    PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown);
+    PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
+    unsigned long long & downloadSize);
 
 
 }
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index ee870f690668..085d83a5b98a 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -540,7 +540,8 @@ static void printMissing(EvalState & state, const DrvInfos & elems)
             targets.insert(i->queryOutPath(state));
     }
 
-    queryMissing(targets, willBuild, willSubstitute, unknown);
+    unsigned long long downloadSize;
+    queryMissing(targets, willBuild, willSubstitute, unknown, downloadSize);
 
     if (!willBuild.empty()) {
         printMsg(lvlInfo, format("the following derivations will be built:"));
@@ -549,7 +550,8 @@ static void printMissing(EvalState & state, const DrvInfos & elems)
     }
 
     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)
             printMsg(lvlInfo, format("  %1%") % *i);
     }