mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
semantic_index: Disable embeddings index for non-staff (#19618)
This PR disables the embeddings index for non-staff users. Release Notes: - N/A
This commit is contained in:
parent
c3860804ff
commit
69b12f4e33
2 changed files with 17 additions and 0 deletions
|
@ -5,6 +5,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Context as _, Result};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
use collections::Bound;
|
use collections::Bound;
|
||||||
|
use feature_flags::FeatureFlagAppExt;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use futures_batch::ChunksTimeoutStreamExt;
|
use futures_batch::ChunksTimeoutStreamExt;
|
||||||
|
@ -15,6 +16,7 @@ use log;
|
||||||
use project::{Entry, UpdatedEntriesSet, Worktree};
|
use project::{Entry, UpdatedEntriesSet, Worktree};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use smol::channel;
|
use smol::channel;
|
||||||
|
use smol::future::FutureExt;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
@ -65,6 +67,10 @@ impl EmbeddingIndex {
|
||||||
&self,
|
&self,
|
||||||
cx: &AppContext,
|
cx: &AppContext,
|
||||||
) -> impl Future<Output = Result<()>> {
|
) -> impl Future<Output = Result<()>> {
|
||||||
|
if !cx.is_staff() {
|
||||||
|
return async move { Ok(()) }.boxed();
|
||||||
|
}
|
||||||
|
|
||||||
let worktree = self.worktree.read(cx).snapshot();
|
let worktree = self.worktree.read(cx).snapshot();
|
||||||
let worktree_abs_path = worktree.abs_path().clone();
|
let worktree_abs_path = worktree.abs_path().clone();
|
||||||
let scan = self.scan_entries(worktree, cx);
|
let scan = self.scan_entries(worktree, cx);
|
||||||
|
@ -75,6 +81,7 @@ impl EmbeddingIndex {
|
||||||
futures::try_join!(scan.task, chunk.task, embed.task, persist)?;
|
futures::try_join!(scan.task, chunk.task, embed.task, persist)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index_updated_entries(
|
pub fn index_updated_entries(
|
||||||
|
@ -82,6 +89,10 @@ impl EmbeddingIndex {
|
||||||
updated_entries: UpdatedEntriesSet,
|
updated_entries: UpdatedEntriesSet,
|
||||||
cx: &AppContext,
|
cx: &AppContext,
|
||||||
) -> impl Future<Output = Result<()>> {
|
) -> impl Future<Output = Result<()>> {
|
||||||
|
if !cx.is_staff() {
|
||||||
|
return async move { Ok(()) }.boxed();
|
||||||
|
}
|
||||||
|
|
||||||
let worktree = self.worktree.read(cx).snapshot();
|
let worktree = self.worktree.read(cx).snapshot();
|
||||||
let worktree_abs_path = worktree.abs_path().clone();
|
let worktree_abs_path = worktree.abs_path().clone();
|
||||||
let scan = self.scan_updated_entries(worktree, updated_entries.clone(), cx);
|
let scan = self.scan_updated_entries(worktree, updated_entries.clone(), cx);
|
||||||
|
@ -92,6 +103,7 @@ impl EmbeddingIndex {
|
||||||
futures::try_join!(scan.task, chunk.task, embed.task, persist)?;
|
futures::try_join!(scan.task, chunk.task, embed.task, persist)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scan_entries(&self, worktree: Snapshot, cx: &AppContext) -> ScanEntries {
|
fn scan_entries(&self, worktree: Snapshot, cx: &AppContext) -> ScanEntries {
|
||||||
|
|
|
@ -336,6 +336,11 @@ mod tests {
|
||||||
|
|
||||||
init_test(cx);
|
init_test(cx);
|
||||||
|
|
||||||
|
cx.update(|cx| {
|
||||||
|
// This functionality is staff-flagged.
|
||||||
|
cx.update_flags(true, vec![]);
|
||||||
|
});
|
||||||
|
|
||||||
let temp_dir = tempfile::tempdir().unwrap();
|
let temp_dir = tempfile::tempdir().unwrap();
|
||||||
|
|
||||||
let mut semantic_index = SemanticDb::new(
|
let mut semantic_index = SemanticDb::new(
|
||||||
|
|
Loading…
Reference in a new issue