disallow opening private files (#7165)
- Disallow sharing gitignored files through collab - Show errors when failing to open files - Show a warning to followers when view is unshared /cc @mikaylamaki, let's update this to use your `private_files` config before merge. Release Notes: - Added the ability to prevent sharing private files over collab. --------- Co-authored-by: Piotr <piotr@zed.dev> Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
c983c9b6df
commit
dcca48482b
9 changed files with 101 additions and 19 deletions
|
@ -56,6 +56,7 @@ use postage::watch;
|
|||
use prettier_support::{DefaultPrettier, PrettierInstance};
|
||||
use project_settings::{LspSettings, ProjectSettings};
|
||||
use rand::prelude::*;
|
||||
use rpc::{ErrorCode, ErrorExt};
|
||||
use search::SearchQuery;
|
||||
use serde::Serialize;
|
||||
use settings::{Settings, SettingsStore};
|
||||
|
@ -1760,7 +1761,7 @@ impl Project {
|
|||
cx.background_executor().spawn(async move {
|
||||
wait_for_loading_buffer(loading_watch)
|
||||
.await
|
||||
.map_err(|error| anyhow!("{project_path:?} opening failure: {error:#}"))
|
||||
.map_err(|e| e.cloned())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -8011,11 +8012,20 @@ impl Project {
|
|||
.update(&mut cx, |this, cx| this.open_buffer_for_symbol(&symbol, cx))?
|
||||
.await?;
|
||||
|
||||
Ok(proto::OpenBufferForSymbolResponse {
|
||||
buffer_id: this.update(&mut cx, |this, cx| {
|
||||
this.create_buffer_for_peer(&buffer, peer_id, cx).into()
|
||||
})?,
|
||||
})
|
||||
this.update(&mut cx, |this, cx| {
|
||||
let is_private = buffer
|
||||
.read(cx)
|
||||
.file()
|
||||
.map(|f| f.is_private())
|
||||
.unwrap_or_default();
|
||||
if is_private {
|
||||
Err(anyhow!(ErrorCode::UnsharedItem))
|
||||
} else {
|
||||
Ok(proto::OpenBufferForSymbolResponse {
|
||||
buffer_id: this.create_buffer_for_peer(&buffer, peer_id, cx).into(),
|
||||
})
|
||||
}
|
||||
})?
|
||||
}
|
||||
|
||||
fn symbol_signature(&self, project_path: &ProjectPath) -> [u8; 32] {
|
||||
|
@ -8037,11 +8047,7 @@ impl Project {
|
|||
let buffer = this
|
||||
.update(&mut cx, |this, cx| this.open_buffer_by_id(buffer_id, cx))?
|
||||
.await?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
Ok(proto::OpenBufferResponse {
|
||||
buffer_id: this.create_buffer_for_peer(&buffer, peer_id, cx).into(),
|
||||
})
|
||||
})?
|
||||
Project::respond_to_open_buffer_request(this, buffer, peer_id, &mut cx)
|
||||
}
|
||||
|
||||
async fn handle_open_buffer_by_path(
|
||||
|
@ -8063,10 +8069,28 @@ impl Project {
|
|||
})?;
|
||||
|
||||
let buffer = open_buffer.await?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
Ok(proto::OpenBufferResponse {
|
||||
buffer_id: this.create_buffer_for_peer(&buffer, peer_id, cx).into(),
|
||||
})
|
||||
Project::respond_to_open_buffer_request(this, buffer, peer_id, &mut cx)
|
||||
}
|
||||
|
||||
fn respond_to_open_buffer_request(
|
||||
this: Model<Self>,
|
||||
buffer: Model<Buffer>,
|
||||
peer_id: proto::PeerId,
|
||||
cx: &mut AsyncAppContext,
|
||||
) -> Result<proto::OpenBufferResponse> {
|
||||
this.update(cx, |this, cx| {
|
||||
let is_private = buffer
|
||||
.read(cx)
|
||||
.file()
|
||||
.map(|f| f.is_private())
|
||||
.unwrap_or_default();
|
||||
if is_private {
|
||||
Err(anyhow!(ErrorCode::UnsharedItem))
|
||||
} else {
|
||||
Ok(proto::OpenBufferResponse {
|
||||
buffer_id: this.create_buffer_for_peer(&buffer, peer_id, cx).into(),
|
||||
})
|
||||
}
|
||||
})?
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue