depot_query: handle missing user info gracefully

This patch handles the case where the pubkey or download location for a
queries depot user is missing.
This commit is contained in:
Norman Feske 2018-02-25 14:27:29 +01:00 committed by Christian Helmuth
parent 7ac9a16090
commit 76b82020d4

View File

@ -298,7 +298,12 @@ struct Depot_query::Main
if (_user_reporter.constructed()) { if (_user_reporter.constructed()) {
_user_reporter->generate([&] (Xml_generator &xml) { _user_reporter->generate([&] (Xml_generator &xml) {
/* query one user only */
bool first = true;
query.for_each_sub_node("user", [&] (Xml_node node) { query.for_each_sub_node("user", [&] (Xml_node node) {
if (!first) return;
first = false;
_query_user(node.attribute_value("name", Archive::User()), xml); }); _query_user(node.attribute_value("name", Archive::User()), xml); });
}); });
} }
@ -542,10 +547,11 @@ void Depot_query::Main::_collect_binary_dependencies(Archive::Path const &path,
void Depot_query::Main::_query_user(Archive::User const &user, Xml_generator &xml) void Depot_query::Main::_query_user(Archive::User const &user, Xml_generator &xml)
{ {
Directory user_dir(_root, Directory::Path("depot/", user));
xml.attribute("name", user); xml.attribute("name", user);
try {
Directory user_dir(_root, Directory::Path("depot/", user));
File_content download(_heap, user_dir, "download", File_content::Limit{4*1024}); File_content download(_heap, user_dir, "download", File_content::Limit{4*1024});
typedef String<256> Url; typedef String<256> Url;
download.for_each_line<Url>([&] (Url const &url) { download.for_each_line<Url>([&] (Url const &url) {
@ -560,6 +566,9 @@ void Depot_query::Main::_query_user(Archive::User const &user, Xml_generator &xm
}); });
}); });
} }
catch (Directory::Nonexistent_file) {
warning("incomplete or missing depot-user info for '", user, "'"); }
}
void Component::construct(Genode::Env &env) { static Depot_query::Main main(env); } void Component::construct(Genode::Env &env) { static Depot_query::Main main(env); }