From de7ceae101eafb7e6c3bf4dca6969e147f5e0bfa Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 19 Apr 2024 21:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ncbi/src/main.rs | 8 ++++++-- ncbi/src/md5sum.rs | 7 ++++++- ncbi/src/task.rs | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ncbi/src/main.rs b/ncbi/src/main.rs index 9d0777e..8b50441 100644 --- a/ncbi/src/main.rs +++ b/ncbi/src/main.rs @@ -82,7 +82,7 @@ enum Mode { Fna { /// library fna 文件存储目录,为了不和原始文件混淆 #[clap(value_parser)] - out_dir: PathBuf, + out_dir: Option, }, /// 仅下载和解析 assembly 文件 Assembly, @@ -205,7 +205,11 @@ async fn async_run(args: Args) -> Result<()> { } }, Some(Mode::Fna { out_dir }) => { - let fna_out_dir = out_dir.join("library").join(grp.clone()); + let fna_out_dir = out_dir + .clone() + .unwrap_or(db_path.clone()) + .join("library") + .join(grp.clone()); utils::create_dir(&fna_out_dir)?; let _ = write_to_fna( &site.to_string(), diff --git a/ncbi/src/md5sum.rs b/ncbi/src/md5sum.rs index 3827a82..41c41e8 100644 --- a/ncbi/src/md5sum.rs +++ b/ncbi/src/md5sum.rs @@ -5,7 +5,12 @@ use tokio::fs::File; use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader}; async fn get_md5_for_file(target_file: &PathBuf, md5_file: &PathBuf) -> Result { - let file = File::open(md5_file).await?; + let file = File::open(md5_file).await.map_err(|e| { + tokio::io::Error::new( + tokio::io::ErrorKind::NotFound, + format!("File operation failed: {:?}-{:?}", md5_file, e), + ) + })?; let reader = BufReader::new(file); let mut lines = reader.lines(); diff --git a/ncbi/src/task.rs b/ncbi/src/task.rs index e3c72d9..2862e8e 100644 --- a/ncbi/src/task.rs +++ b/ncbi/src/task.rs @@ -94,7 +94,7 @@ pub async fn run_task( asm_levels: &Vec<&str>, num_threads: usize, ) -> Result<()> { - log::info!("{} {} download assembly file start...", group, site); + log::info!("{} {} download file start...", group, site); let (tx, rx) = mpsc::channel(4096); // 通道大小可以根据需要调整 let (tx1, rx1) = mpsc::channel(4096); // 通道大小可以根据需要调整 let assembly_tasks = process_assembly_tasks(site, group, data_dir, asm_levels, tx);