updated vector_store to handle for removed files
This commit is contained in:
parent
dce72a1ce7
commit
f5fec55930
1 changed files with 54 additions and 41 deletions
|
@ -635,8 +635,6 @@ impl VectorStore {
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
dbg!(&documents);
|
|
||||||
|
|
||||||
this.read_with(&cx, |this, _| {
|
this.read_with(&cx, |this, _| {
|
||||||
let project_state = if let Some(state) = this.projects.get(&project.downgrade()) {
|
let project_state = if let Some(state) = this.projects.get(&project.downgrade()) {
|
||||||
state
|
state
|
||||||
|
@ -687,6 +685,7 @@ impl VectorStore {
|
||||||
for change in changes.into_iter() {
|
for change in changes.into_iter() {
|
||||||
let change_path = change.0.clone();
|
let change_path = change.0.clone();
|
||||||
let absolute_path = worktree.absolutize(&change_path);
|
let absolute_path = worktree.absolutize(&change_path);
|
||||||
|
|
||||||
// Skip if git ignored or symlink
|
// Skip if git ignored or symlink
|
||||||
if let Some(entry) = worktree.entry_for_id(change.1) {
|
if let Some(entry) = worktree.entry_for_id(change.1) {
|
||||||
if entry.is_ignored || entry.is_symlink || entry.is_external {
|
if entry.is_ignored || entry.is_symlink || entry.is_external {
|
||||||
|
@ -694,6 +693,16 @@ impl VectorStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match change.2 {
|
||||||
|
PathChange::Removed => this.update(&mut cx, |this, _| {
|
||||||
|
this.db_update_tx
|
||||||
|
.try_send(DbOperation::Delete {
|
||||||
|
worktree_id: worktree_db_id,
|
||||||
|
path: absolute_path,
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
}),
|
||||||
|
_ => {
|
||||||
if let Ok(language) = language_registry
|
if let Ok(language) = language_registry
|
||||||
.language_for_file(&change_path.to_path_buf(), None)
|
.language_for_file(&change_path.to_path_buf(), None)
|
||||||
.await
|
.await
|
||||||
|
@ -706,7 +715,8 @@ impl VectorStore {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let modified_time = change_path.metadata().log_err()?.modified().log_err()?;
|
let modified_time =
|
||||||
|
change_path.metadata().log_err()?.modified().log_err()?;
|
||||||
|
|
||||||
let existing_time = file_mtimes.get(&change_path.to_path_buf());
|
let existing_time = file_mtimes.get(&change_path.to_path_buf());
|
||||||
let already_stored = existing_time
|
let already_stored = existing_time
|
||||||
|
@ -714,10 +724,11 @@ impl VectorStore {
|
||||||
|
|
||||||
if !already_stored {
|
if !already_stored {
|
||||||
this.update(&mut cx, |this, _| {
|
this.update(&mut cx, |this, _| {
|
||||||
let reindex_time =
|
let reindex_time = modified_time
|
||||||
modified_time + Duration::from_secs(REINDEXING_DELAY_SECONDS);
|
+ Duration::from_secs(REINDEXING_DELAY_SECONDS);
|
||||||
|
|
||||||
let project_state = this.projects.get_mut(&project.downgrade())?;
|
let project_state =
|
||||||
|
this.projects.get_mut(&project.downgrade())?;
|
||||||
project_state.update_pending_files(
|
project_state.update_pending_files(
|
||||||
PendingFile {
|
PendingFile {
|
||||||
relative_path: change_path.to_path_buf(),
|
relative_path: change_path.to_path_buf(),
|
||||||
|
@ -737,6 +748,8 @@ impl VectorStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Some(())
|
Some(())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue