From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EB8B8B8F4F for ; Tue, 12 Mar 2024 11:10:18 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CB5C515694 for ; Tue, 12 Mar 2024 11:09:48 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 12 Mar 2024 11:09:44 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BCCD643DE9 for ; Tue, 12 Mar 2024 11:09:44 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 12 Mar 2024 11:09:26 +0100 Message-Id: <20240312100926.62899-1-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.038 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox-backup] encoder: merge create_file and create_file_do X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2024 10:10:19 -0000 `create_file` only transforms the path to bytes before calling `create_file_do` with it. Since this is the only caller and the latter method is private, this can be merged into one method to reduce code. Suggested-by: Dietmar Maurer Signed-off-by: Christian Ebner --- src/encoder/mod.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs index 0d342ec..21eb78a 100644 --- a/src/encoder/mod.rs +++ b/src/encoder/mod.rs @@ -340,25 +340,14 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> { file_name: &Path, file_size: u64, ) -> io::Result> - where - 'a: 'b, - { - self.create_file_do(metadata, file_name.as_os_str().as_bytes(), file_size) - .await - } - - async fn create_file_do<'b>( - &'b mut self, - metadata: &Metadata, - file_name: &[u8], - file_size: u64, - ) -> io::Result> where 'a: 'b, { self.check()?; let file_offset = self.position(); + let file_name = file_name.as_os_str().as_bytes(); + self.start_file_do(Some(metadata), file_name).await?; let header = format::Header::with_content_size(format::PXAR_PAYLOAD, file_size); -- 2.39.2