mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 08:12:29 +00:00
nix path-info: Don't write to std::cout directly
This interferes with the progress bar, resulting in output like evaluating derivation 'git+file:///home/eelco/Dev/nix-master#packages.x86_64-linux.default'/nix/store/zz8v96j5md952x0mxfix12xqnvq5qv5x-nix-2.26.0pre20241114_a95f6ea.drv
This commit is contained in:
parent
a95f6ea5c6
commit
33a0fa882f
@ -139,12 +139,12 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
|||||||
|
|
||||||
Category category() override { return catSecondary; }
|
Category category() override { return catSecondary; }
|
||||||
|
|
||||||
void printSize(uint64_t value)
|
void printSize(std::ostream & str, uint64_t value)
|
||||||
{
|
{
|
||||||
if (humanReadable)
|
if (humanReadable)
|
||||||
std::cout << fmt("\t%s", renderSize(value, true));
|
str << fmt("\t%s", renderSize(value, true));
|
||||||
else
|
else
|
||||||
std::cout << fmt("\t%11d", value);
|
str << fmt("\t%11d", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(ref<Store> store, StorePaths && storePaths) override
|
void run(ref<Store> store, StorePaths && storePaths) override
|
||||||
@ -154,11 +154,11 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
|||||||
pathLen = std::max(pathLen, store->printStorePath(storePath).size());
|
pathLen = std::max(pathLen, store->printStorePath(storePath).size());
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
std::cout << pathInfoToJSON(
|
logger->cout(pathInfoToJSON(
|
||||||
*store,
|
*store,
|
||||||
// FIXME: preserve order?
|
// FIXME: preserve order?
|
||||||
StorePathSet(storePaths.begin(), storePaths.end()),
|
StorePathSet(storePaths.begin(), storePaths.end()),
|
||||||
showClosureSize).dump();
|
showClosureSize).dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@ -167,30 +167,32 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
|||||||
auto info = store->queryPathInfo(storePath);
|
auto info = store->queryPathInfo(storePath);
|
||||||
auto storePathS = store->printStorePath(info->path);
|
auto storePathS = store->printStorePath(info->path);
|
||||||
|
|
||||||
std::cout << storePathS;
|
std::ostringstream str;
|
||||||
|
|
||||||
|
str << storePathS;
|
||||||
|
|
||||||
if (showSize || showClosureSize || showSigs)
|
if (showSize || showClosureSize || showSigs)
|
||||||
std::cout << std::string(std::max(0, (int) pathLen - (int) storePathS.size()), ' ');
|
str << std::string(std::max(0, (int) pathLen - (int) storePathS.size()), ' ');
|
||||||
|
|
||||||
if (showSize)
|
if (showSize)
|
||||||
printSize(info->narSize);
|
printSize(str, info->narSize);
|
||||||
|
|
||||||
if (showClosureSize) {
|
if (showClosureSize) {
|
||||||
StorePathSet closure;
|
StorePathSet closure;
|
||||||
store->computeFSClosure(storePath, closure, false, false);
|
store->computeFSClosure(storePath, closure, false, false);
|
||||||
printSize(getStoreObjectsTotalSize(*store, closure));
|
printSize(str, getStoreObjectsTotalSize(*store, closure));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showSigs) {
|
if (showSigs) {
|
||||||
std::cout << '\t';
|
str << '\t';
|
||||||
Strings ss;
|
Strings ss;
|
||||||
if (info->ultimate) ss.push_back("ultimate");
|
if (info->ultimate) ss.push_back("ultimate");
|
||||||
if (info->ca) ss.push_back("ca:" + renderContentAddress(*info->ca));
|
if (info->ca) ss.push_back("ca:" + renderContentAddress(*info->ca));
|
||||||
for (auto & sig : info->sigs) ss.push_back(sig);
|
for (auto & sig : info->sigs) ss.push_back(sig);
|
||||||
std::cout << concatStringsSep(" ", ss);
|
str << concatStringsSep(" ", ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl;
|
logger->cout(str.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user