Skip to content

Commit

Permalink
fix: mark chunks as completed when no failures on retry
Browse files Browse the repository at this point in the history
  • Loading branch information
grumbach committed Dec 5, 2023
1 parent 8c9d676 commit 9e3b05a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 0 additions & 5 deletions sn_cli/src/subcommands/files/chunk_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,6 @@ impl ChunkManager {
.ok()?;
Some(XorName(decoded_xorname))
}

#[allow(dead_code)]
fn hex_encode_xorname(xorname: XorName) -> String {
hex::encode(xorname)
}
}

#[cfg(test)]
Expand Down
10 changes: 9 additions & 1 deletion sn_cli/src/subcommands/files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,15 @@ async fn upload_files(
if chunk_manager.is_chunks_empty() {
// make sure we don't have any failed chunks in those
let chunks = chunk_manager.already_put_chunks(&files_path)?;
let failed_chunks = client.verify_uploaded_chunks(chunks, batch_size).await?;
let failed_chunks = client.verify_uploaded_chunks(&chunks, batch_size).await?;

// mark the non-failed ones as completed
chunk_manager.mark_completed(
chunks
.into_iter()
.filter(|c| !failed_chunks.contains(c))
.map(|(xor, _)| xor),
);

// if none are failed, we can return early
if failed_chunks.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion sn_client/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ impl Client {
/// Returns a vec of any chunks that could not be verified
pub async fn verify_uploaded_chunks(
&self,
chunks_paths: Vec<(XorName, PathBuf)>,
chunks_paths: &[(XorName, PathBuf)],
batch_size: usize,
) -> Result<Vec<(XorName, PathBuf)>> {
let mut failed_chunks = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions sn_client/src/file_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl Files {

let mut failed_chunks = self
.client
.verify_uploaded_chunks(chunks, BATCH_SIZE)
.verify_uploaded_chunks(&chunks, BATCH_SIZE)
.await?;
warn!("Failed chunks: {:?}", failed_chunks.len());

Expand Down Expand Up @@ -319,7 +319,7 @@ impl Files {

failed_chunks = self
.client
.verify_uploaded_chunks(failed_chunks, BATCH_SIZE)
.verify_uploaded_chunks(&failed_chunks, BATCH_SIZE)
.await?;
}

Expand Down

0 comments on commit 9e3b05a

Please sign in to comment.