Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
correct PR remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
musitdev committed Jan 28, 2024
1 parent 11d2020 commit 27e4402
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
23 changes: 7 additions & 16 deletions crates/node/src/asset_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,7 @@ impl AssetManager {
}

async fn process_program(&self, program: &Program) -> Result<()> {
self.download_image(
&program.image_file_url,
program.hash,
&program.image_file_name,
&program.image_file_checksum,
)
.await
self.download_image(program).await
}

async fn process_run(&self, tx: &Transaction) -> Result<()> {
Expand Down Expand Up @@ -169,27 +163,24 @@ impl AssetManager {
/// download downloads file from the given `url` and saves it to file in `file_path`.
async fn download_image(
&self,
url: &str,
program_hash: gevulot_node::types::Hash,
image_file_name: &str,
file_checksum: &str,
program: &Program,
) -> Result<()> {
let file_path = PathBuf::new()
.join("images")
.join(program_hash.to_string())
.join(image_file_name);
.join(program.hash.to_string())
.join(&program.image_file_name);
tracing::info!(
"asset download url:{url} file_path:{file_path:?} file_checksum:{file_checksum}"
"asset download url:{} file_path:{file_path:?} file_checksum:{}", program.image_file_url, program.image_file_checksum
);
crate::networking::download_manager::download_file(
url,
&program.image_file_url,
&self.config.data_directory,
file_path
.to_str()
.ok_or(eyre!("Download bad file path: {:?}", file_path))?,
self.get_peer_list().await,
&self.http_client,
file_checksum.into(),
(&*program.image_file_checksum).into(),
)
.await
}
Expand Down
12 changes: 2 additions & 10 deletions crates/node/src/networking/download_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tokio::net::TcpListener;
use tokio::task::JoinHandle;
use tokio_util::io::ReaderStream;

/// download downloads file from the given `url` and saves it to file in `file_path`.
/// download_file downloads file from the given `url` and saves it to file in `local_directory_path` + / + `file`.
pub async fn download_file(
url: &str,
local_directory_path: &Path,
Expand Down Expand Up @@ -51,15 +51,7 @@ pub async fn download_file(
break;
}
}
match resp {
Some(resp) => resp,
_ => {
return Err(eyre!(
"Download no host found to download the file: {:?}",
file
));
}
}
resp.ok_or(eyre!("Download no host found to download the file: {file:?}"))?
}
};

Expand Down

0 comments on commit 27e4402

Please sign in to comment.