From 28d17f998038a53a46a5aeb8f370520ee030c5ca Mon Sep 17 00:00:00 2001 From: Gaius Date: Tue, 6 Aug 2024 21:21:47 +0800 Subject: [PATCH] feat: add log for deleting piece (#656) Signed-off-by: Gaius --- dragonfly-client-storage/src/metadata.rs | 5 ++- dragonfly-client/src/resource/task.rs | 44 ++++++++++++------------ 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/dragonfly-client-storage/src/metadata.rs b/dragonfly-client-storage/src/metadata.rs index 9dc986f5..bdf4b3ff 100644 --- a/dragonfly-client-storage/src/metadata.rs +++ b/dragonfly-client-storage/src/metadata.rs @@ -787,7 +787,10 @@ impl Metadata { for ele in iter { let (key, _) = ele?; - info!("delete piece metadata {}", task_id); + info!( + "delete piece metadata {}", + std::str::from_utf8(&key).unwrap_or_default().to_string() + ); self.db.delete::(&key)?; } diff --git a/dragonfly-client/src/resource/task.rs b/dragonfly-client/src/resource/task.rs index 0f8a239b..9386ac46 100644 --- a/dragonfly-client/src/resource/task.rs +++ b/dragonfly-client/src/resource/task.rs @@ -1135,28 +1135,6 @@ impl Task { created_at: Some(prost_wkt_types::Timestamp::from(metadata.created_at)), }; - // Send the download piece finished request. - in_stream_tx - .send_timeout( - AnnouncePeerRequest { - host_id: host_id.to_string(), - task_id: task_id.clone(), - peer_id: peer_id.to_string(), - request: Some( - announce_peer_request::Request::DownloadPieceBackToSourceFinishedRequest( - DownloadPieceBackToSourceFinishedRequest { - piece: Some(piece.clone()), - }, - ), - ), - }, - REQUEST_TIMEOUT, - ) - .await.map_err(|err| { - error!("send DownloadPieceBackToSourceFinishedRequest failed: {:?}", err); - err - })?; - // Send the download progress. download_progress_tx .send_timeout( @@ -1180,6 +1158,28 @@ impl Task { err })?; + // Send the download piece finished request. + in_stream_tx + .send_timeout( + AnnouncePeerRequest { + host_id: host_id.to_string(), + task_id: task_id.clone(), + peer_id: peer_id.to_string(), + request: Some( + announce_peer_request::Request::DownloadPieceBackToSourceFinishedRequest( + DownloadPieceBackToSourceFinishedRequest { + piece: Some(piece.clone()), + }, + ), + ), + }, + REQUEST_TIMEOUT, + ) + .await.map_err(|err| { + error!("send DownloadPieceBackToSourceFinishedRequest failed: {:?}", err); + err + })?; + info!( "finished piece {} from source", storage.piece_id(task_id.as_str(), piece.number)