summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/util/update.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gentoobrowse-api/util/update.cpp')
-rw-r--r--gentoobrowse-api/util/update.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/gentoobrowse-api/util/update.cpp b/gentoobrowse-api/util/update.cpp
index bc0082d..01fb263 100644
--- a/gentoobrowse-api/util/update.cpp
+++ b/gentoobrowse-api/util/update.cpp
@@ -8,11 +8,13 @@ int
main(int c, char ** v)
{
std::string endpoint;
- bool background;
+ bool background, tree, bugs;
po::options_description opts("Gentoo Browse Util::Update options");
opts.add_options()
("endpoint", po::value(&endpoint)->default_value("tcp -p 9001"), "Service endpoint")
("background,b", po::value(&background)->default_value(false)->zero_tokens(), "Background")
+ ("bugs", po::value(&bugs)->default_value(true), "Update bugs")
+ ("tree", po::value(&tree)->default_value(true), "Update tree")
("help,h", "Show help")
;
@@ -29,17 +31,28 @@ main(int c, char ** v)
auto m = Gentoo::MaintenancePrx::checkedCast(ic->stringToProxy("maintenance:" + endpoint));
m->ice_ping();
- auto rpt = m->begin_refreshPackageTree();
- auto rb = m->begin_refreshBugs();
- rpt->waitForSent();
- rb->waitForSent();
+ std::set<Ice::AsyncResultPtr> jobs;
+ if (tree) jobs.insert(m->begin_refreshPackageTree());
+ if (bugs) jobs.insert(m->begin_refreshBugs());
+ std::for_each(jobs.begin(), jobs.end(), [](const auto & j) { j->waitForSent(); });
+
+ int failures = 0;
if (!background) {
- m->end_refreshPackageTree(rpt);
- m->end_refreshBugs(rb);
+ std::for_each(jobs.begin(), jobs.end(), [&failures](const auto & j) {
+ try {
+ j->waitForCompleted();
+ j->throwLocalException();
+ }
+ catch (const std::exception & ex) {
+ failures += 1;
+ std::cerr << ex.what() << std::endl;
+ }
+ });
}
+ jobs.clear();
ic->destroy();
- return 0;
+ return failures;
}