diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-11-18 11:23:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-18 11:23:26 +0100 |
| commit | 9230733079101494f803915cbf9f904fe3cdc108 (patch) | |
| tree | 5e0e83eadb4dd02dc5d5aba392139e8de1ee4361 /zellij-server/src/plugins/plugin_loader.rs | |
| parent | docs(changelog): pane-closed event (diff) | |
| download | sl0ppij-9230733079101494f803915cbf9f904fe3cdc108.tar.gz sl0ppij-9230733079101494f803915cbf9f904fe3cdc108.tar.xz sl0ppij-9230733079101494f803915cbf9f904fe3cdc108.zip | |
feat(plugins): add /cache folder (#3787)
* feat(plugins): add /cache folder
* style(fmt): rustfmt
Diffstat (limited to 'zellij-server/src/plugins/plugin_loader.rs')
| -rw-r--r-- | zellij-server/src/plugins/plugin_loader.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/zellij-server/src/plugins/plugin_loader.rs b/zellij-server/src/plugins/plugin_loader.rs index 32d26dd3..760824d7 100644 --- a/zellij-server/src/plugins/plugin_loader.rs +++ b/zellij-server/src/plugins/plugin_loader.rs @@ -60,6 +60,7 @@ pub struct PluginLoader<'a> { plugin_dir: &'a PathBuf, tab_index: Option<usize>, plugin_own_data_dir: PathBuf, + plugin_own_cache_dir: PathBuf, size: Size, wasm_blob_on_hd: Option<(Vec<u8>, PathBuf)>, path_to_default_shell: PathBuf, @@ -344,7 +345,10 @@ impl<'a> PluginLoader<'a> { let plugin_own_data_dir = ZELLIJ_SESSION_CACHE_DIR .join(Url::from(&plugin.location).to_string()) .join(format!("{}-{}", plugin_id, client_id)); - create_plugin_fs_entries(&plugin_own_data_dir)?; + let plugin_own_cache_dir = ZELLIJ_SESSION_CACHE_DIR + .join(Url::from(&plugin.location).to_string()) + .join(format!("plugin_cache")); + create_plugin_fs_entries(&plugin_own_data_dir, &plugin_own_cache_dir)?; let plugin_path = plugin.path.clone(); Ok(PluginLoader { plugin_cache: plugin_cache.clone(), @@ -358,6 +362,7 @@ impl<'a> PluginLoader<'a> { plugin_dir, tab_index, plugin_own_data_dir, + plugin_own_cache_dir, size, wasm_blob_on_hd: None, path_to_default_shell, @@ -789,6 +794,7 @@ impl<'a> PluginLoader<'a> { let dirs = vec![ ("/host".to_owned(), self.zellij_cwd.clone()), ("/data".to_owned(), self.plugin_own_data_dir.clone()), + ("/cache".to_owned(), self.plugin_own_cache_dir.clone()), ("/tmp".to_owned(), ZELLIJ_TMP_DIR.clone()), ]; let dirs = dirs.into_iter().filter(|(_dir_name, dir)| { @@ -825,6 +831,7 @@ impl<'a> PluginLoader<'a> { senders: self.senders.clone(), wasi_ctx, plugin_own_data_dir: self.plugin_own_data_dir.clone(), + plugin_own_cache_dir: self.plugin_own_cache_dir.clone(), tab_index: self.tab_index, path_to_default_shell: self.path_to_default_shell.clone(), capabilities: self.capabilities.clone(), @@ -862,13 +869,19 @@ impl<'a> PluginLoader<'a> { } } -fn create_plugin_fs_entries(plugin_own_data_dir: &PathBuf) -> Result<()> { +fn create_plugin_fs_entries( + plugin_own_data_dir: &PathBuf, + plugin_own_cache_dir: &PathBuf, +) -> Result<()> { let err_context = || "failed to create plugin fs entries"; // Create filesystem entries mounted into WASM. // We create them here to get expressive error messages in case they fail. fs::create_dir_all(&plugin_own_data_dir) .with_context(|| format!("failed to create datadir in {plugin_own_data_dir:?}")) .with_context(err_context)?; + fs::create_dir_all(&plugin_own_cache_dir) + .with_context(|| format!("failed to create cache dir in {plugin_own_cache_dir:?}")) + .with_context(err_context)?; fs::create_dir_all(ZELLIJ_TMP_DIR.as_path()) .with_context(|| format!("failed to create tmpdir at {:?}", &ZELLIJ_TMP_DIR.as_path())) .with_context(err_context)?; |
