Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
a5huynh committed Feb 16, 2023
2 parents a3f38e5 + cc3b423 commit fb74cce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
33 changes: 22 additions & 11 deletions crates/spyglass/src/filesystem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,30 @@ impl SpyglassFileWatcher {
}

// well does this work
for map_ref in &self.ignore_files {
let root = map_ref.key();
let patterns = map_ref.value();
if let Some(parent) = root.parent() {
if path.starts_with(parent) {
return patterns
.matched_path_or_any_parents(path, path.is_dir())
.is_ignore();
let gitignore_checks = self
.ignore_files
.iter()
.filter_map(|map_ref| {
let root = map_ref.key();
let patterns = map_ref.value();
if let Some(parent) = root.parent() {
if path.starts_with(parent) {
return Some(
patterns
.matched_path_or_any_parents(path, path.is_dir())
.is_ignore(),
);
}
}
}
}
None
})
.collect::<Vec<bool>>();

false
if gitignore_checks.is_empty() {
false
} else {
gitignore_checks.iter().any(|b| *b)
}
}

/// Sets up a watcher for the specified path. If two watchers are registered
Expand Down
15 changes: 1 addition & 14 deletions crates/spyglass/src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,7 @@ impl Searcher {

/// Deletes a single entry from the database & index
pub async fn delete_by_id(state: &AppState, doc_id: &str) -> anyhow::Result<()> {
// Remove from search index, immediately.
if let Ok(mut writer) = state.index.writer.lock() {
Searcher::remove_from_index(&mut writer, doc_id)?;
};

// Remove from indexed_doc table
if let Some(model) = indexed_document::Entity::find()
.filter(indexed_document::Column::DocId.eq(doc_id))
.one(&state.db)
.await?
{
let _ = model.delete(&state.db).await;
}

Searcher::delete_many_by_id(state, &[doc_id.into()], true).await?;
Ok(())
}

Expand Down

0 comments on commit fb74cce

Please sign in to comment.