Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nix/app/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ stdenv.mkDerivation {
inherit src;

pname = "nix-uncached";
version = "2.13.1";
version = "2.13.3";
buildInputs = [
nlohmann_json
nix
Expand Down
62 changes: 35 additions & 27 deletions src/nix-uncached.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ int main(int argc, char **argv) {
std::exception_ptr exc;
std::map<InputPath, StringSet> queryPaths;
std::map<InputPath, StringSet> substitutablePaths;
std::map<InputPath, std::vector<std::future<ref<const ValidPathInfo>>>>
futures;

fileTransferSettings.tries = 1;
fileTransferSettings.enableHttp2 = true;

for (auto &storePath : storePaths) {
StorePathSet paths;
Expand All @@ -95,43 +90,56 @@ int main(int argc, char **argv) {
}

for (auto &sub : getDefaultSubstituters()) {
debug("considering '%s' for mass query", sub->getUri());

if (!settings.useSubstitutes)
break;

if (sub->storeDir != store->storeDir)
if (sub->storeDir != store->storeDir) {
debug("discarding '%s' for mass query since '%s' != '%s'", sub->getUri(), sub->storeDir, store->storeDir);
continue;
if (!sub->wantMassQuery)
}

if (!sub->wantMassQuery) {
debug("discarding '%s' for mass query since doesn not want mass query", sub->getUri());
continue;
}

debug("arming '%s' for mass query", sub->getUri());

std::map<InputPath, std::vector<std::future<ref<const ValidPathInfo>>>>
futures;

for (auto &map : queryPaths) {
for (auto &path : map.second)
futures[map.first].push_back(std::async(
[=](std::string path) {
return sub->queryPathInfo(sub->parseStorePath(path));
},
path));
for (auto &path : map.second) {
if(substitutablePaths[map.first].find(path) == substitutablePaths[map.first].end())
futures[map.first].push_back(std::async(
[=](std::string path) {
return sub->queryPathInfo(sub->parseStorePath(path));
},
path));
}
}
}

for (auto &map : futures) {
for (auto &fut : map.second) {
try {
auto info = fut.get();
substitutablePaths[map.first].emplace(
store->printStorePath(info->path));
} catch (InvalidPath &) {
continue;
} catch (...) {
exc = std::current_exception();
for (auto &map : futures) {
for (auto &fut : map.second) {
try {
auto info = fut.get();
substitutablePaths[map.first].emplace(store->printStorePath(info->path));
debug("found '%s'", store->printStorePath(info->path));
} catch (InvalidPath & e) {
continue;
} catch(const std::exception& e) {
debug("Unknown expection: '%s'", e.what());
continue;
}
}
}
}

if (exc)
std::rethrow_exception(exc);

std::map<InputPath, StringSet> uncachedPaths;


for (auto &map : queryPaths) {
if (substitutablePaths.count(map.first))
std::set_difference(map.second.begin(), map.second.end(),
Expand Down