1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

Assistant: Add a new FileProvider to assist in searching the filesystem

When searching in Assistant, we now dispatch some background jobs to
query the whole filesystem. Activating a result will use the Desktop
launcher's default way of opening that file or directory.
This commit is contained in:
Spencer Dixon 2021-07-02 10:36:09 -04:00 committed by Andreas Kling
parent 00f93b2545
commit e6f0b2d817
3 changed files with 100 additions and 1 deletions

View file

@ -120,12 +120,17 @@ public:
explicit Database(AppState& state)
: m_state(state)
{
m_file_provider.build_filesystem_cache();
}
Function<void(Vector<NonnullRefPtr<Result>>)> on_new_results;
void search(String const& query)
{
m_file_provider.query(query, [=, this](auto results) {
recv_results(query, results);
});
m_app_provider.query(query, [=, this](auto results) {
recv_results(query, results);
});
@ -172,6 +177,7 @@ private:
AppProvider m_app_provider;
CalculatorProvider m_calculator_provider;
FileProvider m_file_provider;
Threading::Lock m_lock;
HashMap<String, Vector<NonnullRefPtr<Result>>> m_result_cache;
@ -183,7 +189,7 @@ static constexpr size_t MAX_SEARCH_RESULTS = 6;
int main(int argc, char** argv)
{
if (pledge("stdio recvfd sendfd rpath unix proc exec", nullptr) < 0) {
if (pledge("stdio recvfd sendfd rpath unix proc exec thread", nullptr) < 0) {
perror("pledge");
return 1;
}