Skip to content
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
8 changes: 4 additions & 4 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"homepage": "https://rustsec.org",
"owner": "RustSec",
"repo": "advisory-db",
"rev": "92e5c88a735b5deb50f6c60880e4447da236a591",
"sha256": "1cw2dpj9hb4b52g14vzymahsjikcg0p6d7vm711nspx17w3xgr79",
"rev": "ac125ee29a3b934fc00f52bf56031dc837e9384d",
"sha256": "1mpark5dc64zr3qn564z2idvz44izjpkyihkdgbnwf0ibhv25wpk",
"type": "tarball",
"url": "https://github.com/RustSec/advisory-db/archive/92e5c88a735b5deb50f6c60880e4447da236a591.tar.gz",
"url": "https://github.com/RustSec/advisory-db/archive/ac125ee29a3b934fc00f52bf56031dc837e9384d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"agent-js-monorepo": {
Expand All @@ -34,7 +34,7 @@
"common": {
"branch": "master",
"repo": "ssh://git@github.com/dfinity-lab/common",
"rev": "4b93b09b796fbb62f3c4789e7527a0765eae0cdb",
"rev": "4a65b8341dd4cff0059947b7f2254d09219a90db",
"type": "git"
},
"dfinity": {
Expand Down
10 changes: 3 additions & 7 deletions src/dfx/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ fn write_files_from_entries<R: Sized + Read>(
}

let mut s = String::new();
file.read_to_string(&mut s)
.or_else(|e| Err(DfxError::Io(e)))?;
file.read_to_string(&mut s).map_err(DfxError::Io)?;

// Perform replacements.
variables.iter().for_each(|(name, value)| {
Expand Down Expand Up @@ -292,11 +291,8 @@ fn scaffold_frontend_code(
"dist/".to_owned() + project_name_str + "_assets/",
));

let pretty = serde_json::to_string_pretty(&config_json).or_else(|e| {
Err(DfxError::InvalidData(format!(
"Failed to serialize dfx.json: {}",
e
)))
let pretty = serde_json::to_string_pretty(&config_json).map_err(|e| {
DfxError::InvalidData(format!("Failed to serialize dfx.json: {}", e))
})?;
std::fs::write(&dfx_path, pretty)?;

Expand Down
6 changes: 3 additions & 3 deletions src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
// terminates all sibling processes if a process returns an error,
// which we lack. We consider this a fine trade-off for now.

rcv_wait.recv().or_else(|e| {
Err(DfxError::RuntimeError(Error::new(
rcv_wait.recv().map_err(|e| {
DfxError::RuntimeError(Error::new(
ErrorKind::Other,
format!("Failed while waiting for the manager -- {:?}", e),
)))
))
})?;

// Signal the client to stop. Right now we have little control
Expand Down
6 changes: 1 addition & 5 deletions src/dfx/src/config/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ use std::process::ExitStatus;
// POSIX permissions for files in the cache.
const EXEC_READ_USER_ONLY_PERMISSION: u32 = 0o500;

#[cfg(test)]
use mockall::automock;

#[cfg_attr(test, automock)]
pub trait Cache {
fn version_str(&self) -> String;
fn is_installed(&self) -> DfxResult<bool>;
Expand Down Expand Up @@ -108,7 +104,7 @@ pub fn get_bin_cache(v: &str) -> DfxResult<PathBuf> {
}

pub fn is_version_installed(v: &str) -> DfxResult<bool> {
get_bin_cache(v).and_then(|c| Ok(c.is_dir()))
get_bin_cache(v).map(|c| c.is_dir())
}

pub fn delete_version(v: &str) -> DfxResult<bool> {
Expand Down
8 changes: 2 additions & 6 deletions src/dfx/src/config/dfinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,8 @@ impl Config {
}

pub fn save(&self) -> DfxResult {
let json_pretty = serde_json::to_string_pretty(&self.json).or_else(|e| {
Err(DfxError::InvalidData(format!(
"Failed to serialize dfx.json: {}",
e
)))
})?;
let json_pretty = serde_json::to_string_pretty(&self.json)
.map_err(|e| DfxError::InvalidData(format!("Failed to serialize dfx.json: {}", e)))?;
std::fs::write(&self.path, json_pretty)?;
Ok(())
}
Expand Down
4 changes: 0 additions & 4 deletions src/dfx/src/lib/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::time::Duration;

#[cfg(test)]
use mockall::automock;

#[cfg_attr(test, automock)]
pub trait Environment {
fn get_cache(&self) -> Arc<dyn Cache>;
fn get_config(&self) -> Option<Arc<Config>>;
Expand Down
6 changes: 3 additions & 3 deletions src/dfx/src/lib/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ impl Proxy {
handler
.receiver
.try_recv()
.or_else(|e| {
Err(Error::new(
.map_err(|e| {
Error::new(
ErrorKind::Other,
format!("Failed to shutdown proxy -- {:?}", e),
))
)
})?
.stop(true)
.await;
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/lib/proxy_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn spawn_and_update_proxy(
});
// Stop watching.
let _ = hotwatch;
let proxy = proxy.set_client_api_port(port.clone());
let proxy = proxy.set_client_api_port(port);
b.set_message(format!("Replica bound at {}", port).as_str());
block_on(proxy.restart(
proxy_supervisor.inform_parent.clone(),
Expand Down