From 94952ae77cfcd89cd5b542e76a49acb207eab44f Mon Sep 17 00:00:00 2001 From: Gaius Date: Thu, 15 Aug 2024 21:14:58 +0800 Subject: [PATCH] feat: add with_capacity for content (#671) Signed-off-by: Gaius --- Cargo.toml | 16 ++++++++-------- dragonfly-client/src/grpc/dfdaemon_upload.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 64674b32..53cc8019 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ ] [workspace.package] -version = "0.1.100" +version = "0.1.101" authors = ["The Dragonfly Developers"] homepage = "https://d7y.io/" repository = "https://github.com/dragonflyoss/client.git" @@ -22,13 +22,13 @@ readme = "README.md" edition = "2021" [workspace.dependencies] -dragonfly-client = { path = "dragonfly-client", version = "0.1.100" } -dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.100" } -dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.100" } -dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.100" } -dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.100" } -dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.100" } -dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.100" } +dragonfly-client = { path = "dragonfly-client", version = "0.1.101" } +dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.101" } +dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.101" } +dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.101" } +dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.101" } +dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.101" } +dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.101" } thiserror = "1.0" dragonfly-api = "2.0.148" reqwest = { version = "0.12.4", features = ["stream", "native-tls", "default-tls", "rustls-tls"] } diff --git a/dragonfly-client/src/grpc/dfdaemon_upload.rs b/dragonfly-client/src/grpc/dfdaemon_upload.rs index 531a4130..b2a8bb21 100644 --- a/dragonfly-client/src/grpc/dfdaemon_upload.rs +++ b/dragonfly-client/src/grpc/dfdaemon_upload.rs @@ -791,7 +791,7 @@ impl DfdaemonUpload for DfdaemonUploadServerHandler { })?; // Read the content of the piece. - let mut content = Vec::new(); + let mut content = Vec::with_capacity(piece.length as usize); reader.read_to_end(&mut content).await.map_err(|err| { // Collect upload piece failure metrics. collect_upload_piece_failure_metrics();