Skip to content

Commit

Permalink
fix failing e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Nowak-Liebiediew committed Jul 4, 2023
1 parent 8a666fb commit e256e3d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/dfx/src/lib/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl Environment for EnvironmentImpl {
}

fn new_extension_manager(&self) -> Result<ExtensionManager, ExtensionError> {
ExtensionManager::new(self.get_version())
ExtensionManager::new(self.get_version(), true)
}
}

Expand Down Expand Up @@ -371,7 +371,7 @@ impl<'a> Environment for AgentEnvironment<'a> {
}

fn new_extension_manager(&self) -> Result<ExtensionManager, ExtensionError> {
ExtensionManager::new(self.backend.get_version())
ExtensionManager::new(self.backend.get_version(), true)
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/lib/extension/manager/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use crate::lib::{error::ExtensionError, extension::Extension};

impl ExtensionManager {
pub fn list_installed_extensions(&self) -> Result<Vec<Extension>, ExtensionError> {
if !&self.dir.exists() {
return Ok(vec![]);
}
let dir_content = dfx_core::fs::read_dir(&self.dir)
.map_err(ExtensionError::ExtensionsDirectoryIsNotReadable)?;

Expand Down
8 changes: 5 additions & 3 deletions src/dfx/src/lib/extension/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ pub struct ExtensionManager {
}

impl ExtensionManager {
pub fn new(version: &Version) -> Result<Self, ExtensionError> {
pub fn new(version: &Version, ensure_dir_exists: bool) -> Result<Self, ExtensionError> {
let versioned_cache_dir = get_bin_cache(version.to_string().as_str())
.map_err(ExtensionError::FindCacheDirectoryFailed)?;
let dir = versioned_cache_dir.join("extensions");
dfx_core::fs::composite::ensure_dir_exists(&dir)
.map_err(ExtensionError::EnsureExtensionDirExistsFailed)?;
if ensure_dir_exists {
dfx_core::fs::composite::ensure_dir_exists(&dir)
.map_err(ExtensionError::EnsureExtensionDirExistsFailed)?;
}

Ok(Self {
dir,
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn main() {
let mut error_diagnosis: Diagnosis = NULL_DIAGNOSIS;
let mut args = std::env::args_os().collect::<Vec<OsString>>();

if let Ok(em) = ExtensionManager::new(dfx_version()) {
if let Ok(em) = ExtensionManager::new(dfx_version(), false) {
match em.installed_extensions_as_clap_commands() {
Ok(installed_extensions) if !installed_extensions.is_empty() => {
let mut app = CliOpts::command_for_update().subcommands(&installed_extensions);
Expand Down

0 comments on commit e256e3d

Please sign in to comment.