fix zero size object bug

Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
junxiang Mu
2025-05-08 19:34:58 +08:00
parent 7a94363b38
commit 5cb040f863
2 changed files with 5 additions and 5 deletions

View File

@@ -0,0 +1 @@

View File

@@ -67,7 +67,7 @@ impl Erasure {
{
let (tx, mut rx) = mpsc::channel(5);
let task = tokio::spawn(async move {
let mut buf = Vec::new();
let mut buf = vec![0u8; self.block_size];
let mut total: usize = 0;
loop {
if total_size > 0 {
@@ -99,6 +99,9 @@ impl Erasure {
}
let blocks = Arc::new(Box::pin(self.clone().encode_data(&buf)?));
let _ = tx.send(blocks).await;
if total_size == 0 {
break;
}
}
let etag = reader.etag().await;
Ok((total, etag))
@@ -129,10 +132,6 @@ impl Erasure {
warn!("Erasure encode errs {:?}", &errs);
return Err(err);
}
if total_size == 0 {
break;
}
}
task.await?
}