From e2ffc23d313600f41607179043666b4a1be1f1ec Mon Sep 17 00:00:00 2001 From: Michael Stewart Date: Thu, 11 Oct 2018 15:51:44 -0700 Subject: [PATCH] use NOTION_SANDBOX env var for sandboxing logic in windows --- crates/notion-core/src/path/windows.rs | 9 ++++++--- tests/acceptance/support/sandbox.rs | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/notion-core/src/path/windows.rs b/crates/notion-core/src/path/windows.rs index 690c14cf9..8944f9a59 100644 --- a/crates/notion-core/src/path/windows.rs +++ b/crates/notion-core/src/path/windows.rs @@ -47,7 +47,9 @@ cfg_if! { // launchscript.exe launchscript_file fn program_data_root() -> Fallible { - if let Ok(notion_data) = env::var("NOTION_DATA_ROOT") { + // if this is sandboxed in CI, use the sandboxed ProgramData directory + if env::var("NOTION_SANDBOX").is_ok() { + let notion_data = env::var("NOTION_DATA_ROOT").unwrap(); return Ok(PathBuf::from(notion_data).join("Notion")); } else { #[cfg(windows)] @@ -170,8 +172,9 @@ pub fn shim_file(toolname: &str) -> Fallible { // catalog.toml user_catalog_file fn local_data_root() -> Fallible { - // used to sandbox the acceptance test environment - if let Some(home_dir) = env::home_dir() { + // if this is sandboxed in CI, use the sandboxed AppData directory + if env::var("NOTION_SANDBOX").is_ok() { + let home_dir = env::home_dir().unwrap(); return Ok(home_dir.join("AppData").join("Local").join("Notion")); } else { #[cfg(windows)] diff --git a/tests/acceptance/support/sandbox.rs b/tests/acceptance/support/sandbox.rs index bbd26d47d..0de843d92 100644 --- a/tests/acceptance/support/sandbox.rs +++ b/tests/acceptance/support/sandbox.rs @@ -422,6 +422,7 @@ impl Sandbox { let mut p = test_support::process::process(program); p.cwd(self.root()) // sandbox the Notion environment + .env("NOTION_SANDBOX", "true") // used to indicate that Notion is running sandboxed, for directory logic in Windows .env("HOME", home_dir()) .env("USERPROFILE", home_dir()) // windows .env("NOTION_HOME", notion_home())