]> git.proxmox.com Git - proxmox-backup.git/commitdiff
client: backup writer: only borrow http client
authorChristian Ebner <c.ebner@proxmox.com>
Thu, 28 Mar 2024 12:36:25 +0000 (13:36 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 4 Apr 2024 08:51:45 +0000 (10:51 +0200)
Instead of taking ownership of the http client when starting a new
BackupWriter instance, only borrow the client.

This allows to reuse the http client to later reuse it to start also a
BackupReader instance as required for backup runs with metadata based
file change detection mode, where both must use the same http client.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
examples/upload-speed.rs
pbs-client/src/backup_writer.rs
proxmox-backup-client/src/benchmark.rs
proxmox-backup-client/src/main.rs

index f9fc52a85f6b828ce3abb8c75f13c7a72ad56f47..e4b570ec5854d05f117de594e269353cc3ae75f6 100644 (file)
@@ -18,7 +18,7 @@ async fn upload_speed() -> Result<f64, Error> {
     let backup_time = proxmox_time::epoch_i64();
 
     let client = BackupWriter::start(
-        client,
+        &client,
         None,
         datastore,
         &BackupNamespace::root(),
index 8a03d8ea63511e0f1e9d1cb0a455c867be94b25c..8bd0e4f3691f0923f59fa4a9a12979431dc483bb 100644 (file)
@@ -78,7 +78,7 @@ impl BackupWriter {
     // FIXME: extract into (flattened) parameter struct?
     #[allow(clippy::too_many_arguments)]
     pub async fn start(
-        client: HttpClient,
+        client: &HttpClient,
         crypt_config: Option<Arc<CryptConfig>>,
         datastore: &str,
         ns: &BackupNamespace,
index b3047308c3d369592bc6d5e3b0e77c7ac2de578b..1262fb46d2d75926bcfc4c77c10e482888bf4a97 100644 (file)
@@ -229,7 +229,7 @@ async fn test_upload_speed(
 
     log::debug!("Connecting to backup server");
     let client = BackupWriter::start(
-        client,
+        &client,
         crypt_config.clone(),
         repo.store(),
         &BackupNamespace::root(),
index 546275cb19dcf33ca495ec613f802b8cd905a5d0..148708976f5e4a2c23774176514ca951cce31284 100644 (file)
@@ -834,7 +834,7 @@ async fn create_backup(
 
     let backup_time = backup_time_opt.unwrap_or_else(epoch_i64);
 
-    let client = connect_rate_limited(&repo, rate_limit)?;
+    let http_client = connect_rate_limited(&repo, rate_limit)?;
     record_repository(&repo);
 
     let snapshot = BackupDir::from((backup_type, backup_id.to_owned(), backup_time));
@@ -886,7 +886,7 @@ async fn create_backup(
     };
 
     let client = BackupWriter::start(
-        client,
+        &http_client,
         crypt_config.clone(),
         repo.store(),
         &backup_ns,