mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Do not attempt to reindex a file if previous attempts have failed.
Add doc comment to JobHandle Co-authored-by: Kyle <kyle@zed.dev>
This commit is contained in:
parent
1a88444f2f
commit
61041b0cd1
1 changed files with 17 additions and 0 deletions
|
@ -98,6 +98,8 @@ struct ProjectState {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct JobHandle {
|
struct JobHandle {
|
||||||
|
/// The outer Arc is here to count the clones of a JobHandle instance;
|
||||||
|
/// when the last handle to a given job is dropped, we decrement a counter (just once).
|
||||||
tx: Arc<Weak<Mutex<watch::Sender<usize>>>>,
|
tx: Arc<Weak<Mutex<watch::Sender<usize>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,6 +391,20 @@ impl SemanticIndex {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Insert the file in spite of failure so that future attempts to index it do not take place (unless the file is changed).
|
||||||
|
for (worktree_id, documents, path, mtime, job_handle) in embeddings_queue.into_iter() {
|
||||||
|
db_update_tx
|
||||||
|
.send(DbOperation::InsertFile {
|
||||||
|
worktree_id,
|
||||||
|
documents: vec![],
|
||||||
|
path,
|
||||||
|
mtime,
|
||||||
|
job_handle,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,6 +864,7 @@ impl Entity for SemanticIndex {
|
||||||
impl Drop for JobHandle {
|
impl Drop for JobHandle {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if let Some(inner) = Arc::get_mut(&mut self.tx) {
|
if let Some(inner) = Arc::get_mut(&mut self.tx) {
|
||||||
|
// This is the last instance of the JobHandle (regardless of it's origin - whether it was cloned or not)
|
||||||
if let Some(tx) = inner.upgrade() {
|
if let Some(tx) = inner.upgrade() {
|
||||||
let mut tx = tx.lock();
|
let mut tx = tx.lock();
|
||||||
*tx.borrow_mut() -= 1;
|
*tx.borrow_mut() -= 1;
|
||||||
|
|
Loading…
Reference in a new issue