Skip to content

Commit

Permalink
fix(feat): disable_automatic_asset_installation
Browse files Browse the repository at this point in the history
This fixes a regression in the feature system:
The asset installation didn't get turned off by the feature.

Add error logging to the install functions.

Properly show features in setup

* fix(feat): disable `mkdir` in wasm_wm

The `wasm_vm` creates the `plugin_dir` before mounting it.
Turn that behavior off on `feature-disable-asset-installation`.

Alternative:
    Is this even needed? We make sure the directory is there upon the
    normal asset installation.

fixes #1130
  • Loading branch information
a-kenji committed Mar 16, 2022
1 parent 9c7d139 commit ea6ad5d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ bin-dir = "{ bin }{ binary-ext }"
pkg-fmt = "tgz"

[features]
disable_automatic_asset_installation = []
disable_automatic_asset_installation = [ "zellij-utils/disable_automatic_asset_installation" ]
1 change: 0 additions & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ fn create_new_client() -> ClientInfo {

fn install_default_assets(opts: &CliArgs) {
let data_dir = opts.data_dir.clone().unwrap_or_else(get_default_data_dir);
#[cfg(not(disable_automatic_asset_installation))]
populate_data_dir(&data_dir);
}

Expand Down
13 changes: 10 additions & 3 deletions src/install.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#[cfg(not(feature = "disable_automatic_asset_installation"))]
use std::fs;
use std::path::Path;
#[cfg(not(feature = "disable_automatic_asset_installation"))]
use zellij_utils::{consts::VERSION, shared::set_permissions};

#[cfg(not(feature = "disable_automatic_asset_installation"))]
macro_rules! asset_map {
($($src:literal => $dst:literal),+ $(,)?) => {
{
Expand All @@ -14,6 +17,7 @@ macro_rules! asset_map {
}
}

#[cfg(not(feature = "disable_automatic_asset_installation"))]
pub(crate) fn populate_data_dir(data_dir: &Path) {
// First run installation of default plugins & layouts
let mut assets = asset_map! {
Expand All @@ -29,10 +33,13 @@ pub(crate) fn populate_data_dir(data_dir: &Path) {
for (path, bytes) in assets {
let path = data_dir.join(path);
let parent_path = path.parent().unwrap();
fs::create_dir_all(parent_path).unwrap();
set_permissions(parent_path).unwrap();
fs::create_dir_all(parent_path).unwrap_or_else(|e| log::error!("{:?}", e));
set_permissions(parent_path).unwrap_or_else(|e| log::error!("{:?}", e));
if out_of_date || !path.exists() {
fs::write(path, bytes).expect("Failed to install default assets!");
fs::write(path, bytes).unwrap_or_else(|e| log::error!("Failed to install default assets! {:?}", e));
}
}
}

#[cfg(feature = "disable_automatic_asset_installation")]
pub(crate) fn populate_data_dir(_data_dir: &Path) {}
2 changes: 2 additions & 0 deletions zellij-server/src/wasm_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub(crate) fn wasm_thread_main(
let mut connected_clients: Vec<ClientId> = vec![];
let plugin_dir = data_dir.join("plugins/");
let plugin_global_data_dir = plugin_dir.join("data");

#[cfg(not(feature = "disable_automatic_asset_installation"))]
fs::create_dir_all(&plugin_global_data_dir).unwrap();

loop {
Expand Down
2 changes: 2 additions & 0 deletions zellij-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ features = ["unstable"]
[dev-dependencies]
tempfile = "3.2.0"

[features]
disable_automatic_asset_installation = [ ]

0 comments on commit ea6ad5d

Please sign in to comment.