From 5371b351d4d0d450cc1f89f1b3d20faad81df8f2 Mon Sep 17 00:00:00 2001 From: Sidney Keese Date: Tue, 12 Feb 2019 16:14:23 -0800 Subject: [PATCH] do not download already existing parameters --- filecoin-proofs/src/param.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/filecoin-proofs/src/param.rs b/filecoin-proofs/src/param.rs index 2f75f7ab8..95992eb5a 100644 --- a/filecoin-proofs/src/param.rs +++ b/filecoin-proofs/src/param.rs @@ -44,7 +44,7 @@ pub fn get_local_parameters() -> Result> { .collect()) } else { println!( - "parameter cache directory '{}' does not exist", + "parameter directory '{}' does not exist", path.as_path().to_str().unwrap() ); @@ -112,23 +112,33 @@ pub fn fetch_parameter_file(parameter: String) -> Result<()> { let mut path = parameter_cache_dir(); path.push(parameter); - let output = Command::new("curl") - .arg("-o") - .arg(path.as_path().to_str().unwrap().to_string()) - .arg(format!("https://ipfs.io/ipfs/{}", cid)) - .output() - .expect(ERROR_CURL_COMMAND); + if path.exists() { + println!( + "parameter file '{}' already exists", + path.as_path().to_str().unwrap() + ); - if !output.status.success() { - Err(err_msg(ERROR_CURL_FETCH)) - } else { Ok(()) + } else { + let output = Command::new("curl") + .arg("-o") + .arg(path.as_path().to_str().unwrap().to_string()) + .arg(format!("https://ipfs.io/ipfs/{}", cid)) + .output() + .expect(ERROR_CURL_COMMAND); + + if !output.status.success() { + Err(err_msg(ERROR_CURL_FETCH)) + } else { + Ok(()) + } } } pub fn choose(message: String) -> bool { loop { print!("{} [y/n]: ", message); + let _ = stdout().flush(); let mut s = String::new(); stdin().read_line(&mut s).expect(ERROR_STRING);