Skip to content

Commit 886400b

Browse files
authored
fix: correct datasource ID in returned documents (#396)
* fix: correct datasource ID in returned documents
1 parent 53258ee commit 886400b

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src-tauri/src/local/application.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use std::path::PathBuf;
1111
use tauri::{AppHandle, Runtime};
1212
use tauri_plugin_fs_pro::{icon, metadata, name, IconOptions};
1313

14+
const DATA_SOURCE_ID: &str = "Applications";
15+
1416
#[tauri::command]
1517
pub fn get_default_search_paths() -> Vec<String> {
1618
#[cfg(target_os = "macos")]
@@ -232,7 +234,7 @@ impl SearchSource for ApplicationSearchSource {
232234
.unwrap_or("My Computer".into())
233235
.to_string_lossy()
234236
.into(),
235-
id: "local_applications".into(),
237+
id: DATA_SOURCE_ID.into(),
236238
}
237239
}
238240

@@ -282,8 +284,8 @@ impl SearchSource for ApplicationSearchSource {
282284
let mut doc = Document::new(
283285
Some(DataSourceReference {
284286
r#type: Some(LOCAL_QUERY_SOURCE_TYPE.into()),
285-
name: Some("Applications".into()),
286-
id: Some(app_name.clone()),
287+
name: Some(DATA_SOURCE_ID.into()),
288+
id: Some(DATA_SOURCE_ID.into()),
287289
icon: None,
288290
}),
289291
app_path_string.clone(),

src-tauri/src/search/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub async fn query_coco_fusion<R: Runtime>(
1717
size: u64,
1818
query_strings: HashMap<String, String>,
1919
) -> Result<MultiSourceQueryResponse, SearchError> {
20+
let data_source_to_search = query_strings.get("datasource");
21+
2022
let search_sources = app_handle.state::<SearchSourceRegistry>();
2123

2224
let sources_future = search_sources.get_sources();
@@ -31,6 +33,14 @@ pub async fn query_coco_fusion<R: Runtime>(
3133
// Push all queries into futures
3234
for query_source in sources_list {
3335
let query_source_type = query_source.get_type().clone();
36+
37+
if let Some(data_source_to_search) = data_source_to_search {
38+
// We should not search this data source
39+
if &query_source_type.id != data_source_to_search {
40+
continue;
41+
}
42+
}
43+
3444
sources.insert(query_source_type.id.clone(), query_source_type);
3545

3646
let query = SearchQuery::new(from, size, query_strings.clone());
@@ -41,7 +51,7 @@ pub async fn query_coco_fusion<R: Runtime>(
4151
timeout(timeout_duration, async {
4252
query_source_clone.search(query).await
4353
})
44-
.await
54+
.await
4555
}));
4656
}
4757

0 commit comments

Comments
 (0)