summaryrefslogtreecommitdiff
path: root/src/chunker/rw/storage/write/simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/chunker/rw/storage/write/simple.rs')
-rw-r--r--src/chunker/rw/storage/write/simple.rs44
1 files changed, 8 insertions, 36 deletions
diff --git a/src/chunker/rw/storage/write/simple.rs b/src/chunker/rw/storage/write/simple.rs
index 461afff..c7a20ea 100644
--- a/src/chunker/rw/storage/write/simple.rs
+++ b/src/chunker/rw/storage/write/simple.rs
@@ -1,6 +1,6 @@
use futures::future::join_all;
use just_progress::progress;
-use log::{error, info, trace};
+use log::{debug, error, trace};
use std::{
collections::HashMap,
path::{Path, PathBuf},
@@ -15,8 +15,7 @@ use crate::{
storage::{self, ChunkInfo, bidx::write_bidx_file, hash::ChunkWriteHash},
},
},
- storage::get_index_file_name,
- utils::size_display::size_display,
+ storage::{display_boundaries, get_index_file_name},
};
pub async fn write_file_simple(
@@ -92,7 +91,7 @@ async fn write_file_to_storage(
ctx.storage_path.as_ref().unwrap().display()
);
- info!(
+ debug!(
"{} chunks will be written to {}",
chunk_count,
ctx.storage_path.as_ref().unwrap().display()
@@ -182,7 +181,7 @@ async fn write_file_to_storage(
}
}
- info!("All {} chunks written successfully", success_count);
+ debug!("All {} chunks written successfully", success_count);
// Write index file
trace!("Writing index file to: {}", output_index_file.display());
@@ -190,7 +189,7 @@ async fn write_file_to_storage(
error!("Failed to write index file: {}", e);
return Err(ButckRWErrorKind::IOError(e));
}
- info!("Index file written to: {}", output_index_file.display());
+ debug!("Index file written to: {}", output_index_file.display());
trace!("write_file_to_storage completed successfully");
@@ -254,6 +253,9 @@ async fn write_chunk(params: WriteChunkParams) -> Result<ChunkInfo, ButckRWError
params.chunk_index,
params.chunk_data.len()
);
+
+ progress::increase(&params.progress_name, params.step as f32);
+
if !file_path.exists() {
tokio::fs::write(&file_path, &params.chunk_data).await?;
} else {
@@ -266,7 +268,6 @@ async fn write_chunk(params: WriteChunkParams) -> Result<ChunkInfo, ButckRWError
"write_chunk[{}]: File written successfully",
params.chunk_index
);
- progress::increase(&params.progress_name, params.step as f32);
Ok(ChunkInfo {
index: params.chunk_index,
hash: hash_hex,
@@ -292,32 +293,3 @@ async fn write_index_file(
) -> Result<(), std::io::Error> {
write_bidx_file(index_path, chunk_infos, original_file_path)
}
-
-pub async fn display_boundaries(chunk_boundaries: &[u32], total_bytes: usize) {
- let total_chunks = chunk_boundaries.len() + 1;
- let (total_value, total_unit) = size_display(total_bytes);
- info!(
- "{} chunks, ({:.2} {}, {})",
- total_chunks, total_value, total_unit, total_bytes
- );
- let mut start = 0;
- chunk_boundaries.iter().for_each(|p| {
- let next = *p as usize;
- let (size_value, size_unit) = size_display(next - start);
- info!(
- "{} - {} (size: {:.2} {})",
- start,
- next - 1,
- size_value,
- size_unit
- );
- start = next;
- });
- let last = start;
- let r#final = total_bytes;
- let (size_value, size_unit) = size_display(total_bytes - start);
- info!(
- "{} - {} (size: {:.2} {})",
- last, r#final, size_value, size_unit
- );
-}