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 362F86AF7A for ; Mon, 25 Jan 2021 14:43:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2D865ACB4 for ; Mon, 25 Jan 2021 14:43:18 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id A079EACA9 for ; Mon, 25 Jan 2021 14:43:17 +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 6CC0845717 for ; Mon, 25 Jan 2021 14:43:17 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Mon, 25 Jan 2021 14:42:48 +0100 Message-Id: <20210125134302.3394328-4-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210125134302.3394328-1-f.gruenbichler@proxmox.com> References: <20210125134302.3394328-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 03/15] client: refactor catalog upload spawning 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: Mon, 25 Jan 2021 13:43:48 -0000 by pulling out Result type into separate struct Signed-off-by: Fabian Grünbichler --- especially unhappy with the name here.. src/bin/proxmox-backup-client.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 041a670c..dce8f0b8 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -586,21 +586,21 @@ async fn start_garbage_collection(param: Value) -> Result { Ok(Value::Null) } +struct CatalogUploadResult { + catalog_writer: Arc>>, + result: tokio::sync::oneshot::Receiver>, +} + fn spawn_catalog_upload( client: Arc, encrypt: bool, -) -> Result< - ( - Arc>>, - tokio::sync::oneshot::Receiver> - ), Error> -{ +) -> Result { let (catalog_tx, catalog_rx) = std::sync::mpsc::sync_channel(10); // allow to buffer 10 writes let catalog_stream = crate::tools::StdChannelStream(catalog_rx); let catalog_chunk_size = 512*1024; let catalog_chunk_stream = ChunkStream::new(catalog_stream, Some(catalog_chunk_size)); - let catalog = Arc::new(Mutex::new(CatalogWriter::new(crate::tools::StdChannelWriter::new(catalog_tx))?)); + let catalog_writer = Arc::new(Mutex::new(CatalogWriter::new(crate::tools::StdChannelWriter::new(catalog_tx))?)); let (catalog_result_tx, catalog_result_rx) = tokio::sync::oneshot::channel(); @@ -617,7 +617,7 @@ fn spawn_catalog_upload( let _ = catalog_result_tx.send(catalog_upload_result); }); - Ok((catalog, catalog_result_rx)) + Ok(CatalogUploadResult { catalog_writer, result: catalog_result_rx }) } fn keyfile_parameters(param: &Value) -> Result<(Option>, CryptMode), Error> { @@ -990,7 +990,7 @@ async fn create_backup( let mut manifest = BackupManifest::new(snapshot); let mut catalog = None; - let mut catalog_result_tx = None; + let mut catalog_result_rx = None; for (backup_type, filename, target, size) in upload_list { match backup_type { @@ -1011,9 +1011,9 @@ async fn create_backup( BackupSpecificationType::PXAR => { // start catalog upload on first use if catalog.is_none() { - let (cat, res) = spawn_catalog_upload(client.clone(), crypt_mode == CryptMode::Encrypt)?; - catalog = Some(cat); - catalog_result_tx = Some(res); + let catalog_upload_res = spawn_catalog_upload(client.clone(), crypt_mode == CryptMode::Encrypt)?; + catalog = Some(catalog_upload_res.catalog_writer); + catalog_result_rx = Some(catalog_upload_res.result); } let catalog = catalog.as_ref().unwrap(); @@ -1065,7 +1065,7 @@ async fn create_backup( drop(catalog); // close upload stream - if let Some(catalog_result_rx) = catalog_result_tx { + if let Some(catalog_result_rx) = catalog_result_rx { let stats = catalog_result_rx.await??; manifest.add_file(CATALOG_NAME.to_owned(), stats.size, stats.csum, crypt_mode)?; } -- 2.20.1