diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-11-12 16:51:11 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-11-12 16:51:11 +0000 |
commit | fa72e4952344c85b34cfe8eabe5c51b9f7090e69 (patch) | |
tree | 8fdccb8d056cb317977be038f3e5ab11d8f0ccb1 | |
parent | Add test dependency on cd (diff) | |
download | gentoobrowse-fa72e4952344c85b34cfe8eabe5c51b9f7090e69.tar.bz2 gentoobrowse-fa72e4952344c85b34cfe8eabe5c51b9f7090e69.tar.xz gentoobrowse-fa72e4952344c85b34cfe8eabe5c51b9f7090e69.zip |
Don't assume packages and categories are present
They might be missing because caching
-rw-r--r-- | gentoobrowse/src/packages.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gentoobrowse/src/packages.cpp b/gentoobrowse/src/packages.cpp index c6e01fb..3ef592d 100644 --- a/gentoobrowse/src/packages.cpp +++ b/gentoobrowse/src/packages.cpp @@ -58,21 +58,25 @@ namespace GentooBrowse { if (_responseModel->user) { _ar_t = prx1->trackedAsync(_responseModel->user->userid); } - auto ebuilds = _ar_ebuilds.get(); - auto packages = GentooBrowse::makeMap<Ice::Int, Gentoo::PackagePtr>(_ar_packages.get(), [](auto p){ return p->packageid; }); - auto categories = GentooBrowse::makeMap<Ice::Int, Gentoo::CategoryPtr>(_ar_categories.get(), [](auto c){ return c->categoryid; }); + const auto ebuilds = _ar_ebuilds.get(); + const auto packages = GentooBrowse::makeMap<Ice::Int, Gentoo::PackagePtr>(_ar_packages.get(), [](auto p){ return p->packageid; }); + const auto categories = GentooBrowse::makeMap<Ice::Int, Gentoo::CategoryPtr>(_ar_categories.get(), [](auto c){ return c->categoryid; }); ::Gentoo::PackageIds tracked; if (_responseModel->user) { tracked = _ar_t.get(); } for(const auto & ebuild : ebuilds) { - auto & p = packages[ebuild->packageid]; - auto & c = categories[p->categoryid]; - auto & s = _responseModel->syncs[ebuild->firstseen.substr(0, 10)]; - bool isTracked = std::find(tracked.begin(), tracked.end(), p->packageid) != tracked.end(); - auto & pw = s[{ isTracked, c->name }][{ isTracked, p->name }]; - if (!pw.detail) pw.detail = p; - pw.ebuilds.push_back(ebuild); + if (auto pi = packages.find(ebuild->packageid); pi != packages.end()) { + auto & p = pi->second; + if (auto ci = categories.find(p->categoryid); ci != categories.end()) { + auto & c = ci->second; + auto & s = _responseModel->syncs[ebuild->firstseen.substr(0, 10)]; + bool isTracked = std::find(tracked.begin(), tracked.end(), p->packageid) != tracked.end(); + auto & pw = s[{ isTracked, c->name }][{ isTracked, p->name }]; + if (!pw.detail) pw.detail = p; + pw.ebuilds.push_back(ebuild); + } + } } request->response(this, _responseModel); } |