extension_host: Add capability for downloading files (#35141)
This PR adds a new capability for downloading files in extensions. Currently all file downloads are allowed. Release Notes: - N/A
This commit is contained in:
parent
d7b403e981
commit
6a9a539b10
6 changed files with 165 additions and 12 deletions
|
@ -30,6 +30,7 @@ use std::{
|
|||
sync::{Arc, OnceLock},
|
||||
};
|
||||
use task::{SpawnInTerminal, ZedDebugConfig};
|
||||
use url::Url;
|
||||
use util::{archive::extract_zip, fs::make_file_executable, maybe};
|
||||
use wasmtime::component::{Linker, Resource};
|
||||
|
||||
|
@ -1011,6 +1012,9 @@ impl ExtensionImports for WasmState {
|
|||
file_type: DownloadedFileType,
|
||||
) -> wasmtime::Result<Result<(), String>> {
|
||||
maybe!(async {
|
||||
let parsed_url = Url::parse(&url)?;
|
||||
self.capability_granter.grant_download_file(&parsed_url)?;
|
||||
|
||||
let path = PathBuf::from(path);
|
||||
let extension_work_dir = self.host.work_dir.join(self.manifest.id.as_ref());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue