forked from cromer/pamac-classic
fix #183
This commit is contained in:
parent
eead56555a
commit
9bcd61cfb7
23
src/aur.vala
23
src/aur.vala
@ -52,25 +52,24 @@ namespace AUR {
|
|||||||
public async Json.Array search (string[] needles) {
|
public async Json.Array search (string[] needles) {
|
||||||
if (needles.length == 0) {
|
if (needles.length == 0) {
|
||||||
return new Json.Array ();
|
return new Json.Array ();
|
||||||
} else if (needles.length == 1) {
|
|
||||||
return rpc_query (rpc_url + rpc_search + Uri.escape_string (needles[0]));
|
|
||||||
} else {
|
} else {
|
||||||
var inter = new Json.Array ();
|
var result = rpc_query (rpc_url + rpc_search + Uri.escape_string (needles[0]));
|
||||||
var prev_inter = new Json.Array ();
|
int i = 1;
|
||||||
foreach (unowned string needle in needles) {
|
while (i < needles.length) {
|
||||||
inter = new Json.Array ();
|
var inter = new Json.Array ();
|
||||||
var found = rpc_query (rpc_url + rpc_search + Uri.escape_string (needle));
|
var found = rpc_query (rpc_url + rpc_search + Uri.escape_string (needles[i]));
|
||||||
prev_inter.foreach_element ((prev_inter_array, prev_inter_index, prev_inter_node) => {
|
result.foreach_element ((result_array, result_index, result_node) => {
|
||||||
found.foreach_element ((found_array, found_index, found_node) => {
|
found.foreach_element ((found_array, found_index, found_node) => {
|
||||||
if (strcmp (prev_inter_node.get_object ().get_string_member ("Name"),
|
if (strcmp (result_node.get_object ().get_string_member ("Name"),
|
||||||
found_node.get_object ().get_string_member ("Name")) == 0) {
|
found_node.get_object ().get_string_member ("Name")) == 0) {
|
||||||
inter.add_element (prev_inter_node);
|
inter.add_element (result_node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
prev_inter = (owned) inter;
|
result = (owned) inter;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
return inter;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user