mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-19 00:10:00 +00:00
- Restricted Mode git: reads run without a signature verifier, hooks (including config-defined ones), an external diff, filters or a lazy fetch, also inside submodules; every repository and every git starts restricted until the project is trusted. - project.write and plugin quick fixes cannot reach git's own files under any spelling or through links; project.write is a high-risk grant. - Built-in web server: each served root has its own port and token; a file outside the project is served with its folder minus dot names, or alone when that folder is the home folder or above it; no fixed port. - Images, references, Markdown links and language-server links reach no network share other than the one already open. - Marketplace: entries whose id or version no manifest may carry are dropped; an index read over the network names nothing on this machine; network reads are bounded in size and time. - Agent replies load remote images on a click; the Markdown preview and Mermaid configuration no longer fetch from other hosts.
35 lines
1.6 KiB
Rust
35 lines
1.6 KiB
Rust
//! Raw file bytes for the image viewer and hex view (see `ide_vfs::bytes`).
|
|
use crate::Host;
|
|
use crate::rpc::Dispatcher;
|
|
|
|
use crate::ops::doc::blocking;
|
|
use ide_core::IdeResult;
|
|
use ide_vfs::{ByteRange, FileProbe};
|
|
use std::path::PathBuf;
|
|
|
|
/// Size and text/binary classification, from the file's head only.
|
|
pub async fn fs_probe(_host: &Host, _window: &str, path: PathBuf) -> IdeResult<FileProbe> {
|
|
blocking(move || ide_vfs::probe(&path)).await
|
|
}
|
|
|
|
/// Up to `len` bytes from `offset` (capped per call), base64-encoded.
|
|
pub async fn fs_read_range(_host: &Host, _window: &str, path: PathBuf, offset: u64, len: u32) -> IdeResult<ByteRange> {
|
|
blocking(move || ide_vfs::read_range(&path, offset, len)).await
|
|
}
|
|
|
|
/// An image file as a `data:` URL. A network path is read only from a share an open project is
|
|
/// on: the path may come from Markdown, and opening a share signs in to its server.
|
|
pub async fn fs_read_image(host: &Host, _window: &str, path: PathBuf) -> IdeResult<String> {
|
|
let opened: Vec<PathBuf> = host.projects().iter().map(|project| project.root.clone()).collect();
|
|
blocking(move || ide_vfs::read_data_url(&path, &opened)).await
|
|
}
|
|
|
|
/// Commands of this module the remote server answers.
|
|
pub(crate) fn register(d: &mut Dispatcher) {
|
|
d.add("fs_probe", |c| async move { fs_probe(&c.host, &c.window, c.arg("path")?).await });
|
|
d.add("fs_read_range", |c| async move {
|
|
fs_read_range(&c.host, &c.window, c.arg("path")?, c.arg("offset")?, c.arg("len")?).await
|
|
});
|
|
d.add("fs_read_image", |c| async move { fs_read_image(&c.host, &c.window, c.arg("path")?).await });
|
|
}
|