printSize() fixes
Fix a 32-bit overflow that resulted in negative numbers being printed; use fmt() instead of boost::format(); change -H to -h for consistency with 'ls' and 'du'; make the columns narrower (since they can't be bigger than 1024.0).
This commit is contained in:
parent
c908df881f
commit
99828245f8
1 changed files with 5 additions and 7 deletions
|
@ -5,8 +5,6 @@
|
||||||
#include "common-args.hh"
|
#include "common-args.hh"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/format.hpp>
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
|
@ -21,7 +19,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
||||||
{
|
{
|
||||||
mkFlag('s', "size", "print size of the NAR dump of each path", &showSize);
|
mkFlag('s', "size", "print size of the NAR dump of each path", &showSize);
|
||||||
mkFlag('S', "closure-size", "print sum size of the NAR dumps of the closure of each path", &showClosureSize);
|
mkFlag('S', "closure-size", "print sum size of the NAR dumps of the closure of each path", &showClosureSize);
|
||||||
mkFlag('H', "human-readable", "with -s and -S, print sizes like 1K 234M 5.67G etc.", &humanReadable);
|
mkFlag('h', "human-readable", "with -s and -S, print sizes like 1K 234M 5.67G etc.", &humanReadable);
|
||||||
mkFlag(0, "sigs", "show signatures", &showSigs);
|
mkFlag(0, "sigs", "show signatures", &showSigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +42,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
||||||
},
|
},
|
||||||
Example{
|
Example{
|
||||||
"To show a package's closure size and all its dependencies with human readable sizes:",
|
"To show a package's closure size and all its dependencies with human readable sizes:",
|
||||||
"nix path-info -rsSH nixpkgs.rust"
|
"nix path-info -rsSh nixpkgs.rust"
|
||||||
},
|
},
|
||||||
Example{
|
Example{
|
||||||
"To check the existence of a path in a binary cache:",
|
"To check the existence of a path in a binary cache:",
|
||||||
|
@ -65,10 +63,10 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void printSize(int value)
|
void printSize(unsigned long long value)
|
||||||
{
|
{
|
||||||
if (!humanReadable) {
|
if (!humanReadable) {
|
||||||
std::cout << '\t' << boost::format("%11d") % value;
|
std::cout << fmt("\t%11d", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +79,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
||||||
++power;
|
++power;
|
||||||
res /= 1024;
|
res /= 1024;
|
||||||
}
|
}
|
||||||
std::cout << '\t' << boost::format("%11.1f") % res << idents[power];
|
std::cout << fmt("\t%6.1f%c", res, idents.at(power));
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(ref<Store> store, Paths storePaths) override
|
void run(ref<Store> store, Paths storePaths) override
|
||||||
|
|
Loading…
Reference in a new issue