Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wasm_vm): use cache_dirs for ephemeral plugin data #1230

Merged
merged 5 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions zellij-server/src/wasm_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::{
};

use zellij_utils::{
consts::{VERSION, ZELLIJ_PROJ_DIR, ZELLIJ_TMP_DIR},
consts::{VERSION, ZELLIJ_CACHE_DIR, ZELLIJ_PROJ_DIR, ZELLIJ_TMP_DIR},
errors::{ContextType, PluginContext},
};
use zellij_utils::{
Expand Down Expand Up @@ -106,14 +106,7 @@ pub(crate) fn wasm_thread_main(
.unwrap_or_else(|| panic!("Plugin {:?} could not be resolved", run));

let (instance, plugin_env) = start_plugin(
plugin_id,
client_id,
&plugin,
tab_index,
&bus,
&store,
&data_dir,
&plugin_global_data_dir,
plugin_id, client_id, &plugin, tab_index, &bus, &store, &data_dir,
);

let mut main_user_instance = instance.clone();
Expand Down Expand Up @@ -204,16 +197,8 @@ pub(crate) fn wasm_thread_main(
// load headless plugins
for plugin in plugins.iter() {
if let PluginType::Headless = plugin.run {
let (instance, plugin_env) = start_plugin(
plugin_id,
client_id,
plugin,
0,
&bus,
&store,
&data_dir,
&plugin_global_data_dir,
);
let (instance, plugin_env) =
start_plugin(plugin_id, client_id, plugin, 0, &bus, &store, &data_dir);
headless_plugins.insert(plugin_id, (instance, plugin_env));
plugin_id += 1;
}
Expand All @@ -238,7 +223,6 @@ fn start_plugin(
bus: &Bus<PluginInstruction>,
store: &Store,
data_dir: &Path,
plugin_global_data_dir: &Path,
) -> (Instance, PluginEnv) {
if plugin._allow_exec_host_cmd {
info!(
Expand Down Expand Up @@ -271,7 +255,7 @@ fn start_plugin(
let output = Pipe::new();
let input = Pipe::new();
let stderr = LoggingPipe::new(&plugin.location.to_string(), plugin_id);
let plugin_own_data_dir = plugin_global_data_dir.join(Url::from(&plugin.location).to_string());
let plugin_own_data_dir = ZELLIJ_CACHE_DIR.join(Url::from(&plugin.location).to_string());
fs::create_dir_all(&plugin_own_data_dir).unwrap_or_else(|e| {
log::error!(
"Could not create plugin_own_data_dir in {:?} \n Error: {:?}",
Expand Down
1 change: 1 addition & 0 deletions zellij-utils/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ lazy_static! {
pub static ref ZELLIJ_TMP_DIR: PathBuf = PathBuf::from(format!("/tmp/zellij-{}", *UID));
pub static ref ZELLIJ_TMP_LOG_DIR: PathBuf = ZELLIJ_TMP_DIR.join("zellij-log");
pub static ref ZELLIJ_TMP_LOG_FILE: PathBuf = ZELLIJ_TMP_LOG_DIR.join("zellij.log");
pub static ref ZELLIJ_CACHE_DIR: PathBuf = ZELLIJ_PROJ_DIR.cache_dir().to_path_buf();
}

pub const FEATURES: &[&str] = &[
Expand Down