about summary refs log tree commit diff
path: root/src/nix/path-info.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-21T15·53+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-21T15·53+0200
commit7d14f5c3310f5380ca14391e79bd1fc214d5f5c9 (patch)
tree2e02ef91dc6824859c828459b2c19e95d0f096da /src/nix/path-info.cc
parentd155d8015578c43953e4a9d1867e49c0b71534d7 (diff)
Implement S3BinaryCacheStore::queryAllValidPaths()
This allows commands like "nix verify --all" or "nix path-info --all"
to work on S3 caches.

Unfortunately, this requires some ugly hackery: when querying the
contents of the bucket, we don't want to have to read every .narinfo
file. But the S3 bucket keys only include the hash part of each store
path, not the name part. So as a special exception
queryAllValidPaths() can now return store paths *without* the name
part, and queryPathInfo() accepts such store paths (returning a
ValidPathInfo object containing the full name).
Diffstat (limited to 'src/nix/path-info.cc')
-rw-r--r--src/nix/path-info.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nix/path-info.cc b/src/nix/path-info.cc
index 8497d708c3f0..d144ef082977 100644
--- a/src/nix/path-info.cc
+++ b/src/nix/path-info.cc
@@ -4,6 +4,7 @@
 #include "store-api.hh"
 
 #include <iomanip>
+#include <algorithm>
 
 using namespace nix;
 
@@ -48,14 +49,14 @@ struct CmdPathInfo : StorePathsCommand
         for (auto & storePath : storePaths)
             pathLen = std::max(pathLen, storePath.size());
 
-        for (auto & storePath : storePaths) {
-            if (!store->isValidPath(storePath))
-                throw Error(format("path ‘%s’ is not valid") % storePath);
+        for (auto storePath : storePaths) {
+            auto info = store->queryPathInfo(storePath);
+            storePath = info->path; // FIXME: screws up padding
 
-            std::cout << storePath << std::string(pathLen - storePath.size(), ' ');
+            std::cout << storePath << std::string(std::max(0, (int) pathLen - (int) storePath.size()), ' ');
 
             if (showSize) {
-                std::cout << '\t' << std::setw(11) << store->queryPathInfo(storePath)->narSize;
+                std::cout << '\t' << std::setw(11) << info->narSize;
             }
 
             if (showClosureSize) {