From aa174e8e8acea11a293671dfe8ab8a2ead1408d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 30 Dec 2021 13:20:03 +0100 Subject: [PATCH] tree-wide: drop redundant clones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- pbs-client/src/tools/key_source.rs | 4 ++-- pbs-config/src/tape_encryption_keys.rs | 2 +- proxmox-file-restore/src/block_driver_qemu.rs | 2 +- proxmox-rest-server/src/worker_task.rs | 4 ++-- .../src/proxmox_restore_daemon/disk.rs | 2 +- proxmox-rrd/src/cache.rs | 4 ++-- src/api2/access/openid.rs | 5 ++--- src/api2/admin/datastore.rs | 2 +- src/api2/tape/restore.rs | 5 ++--- src/bin/proxmox-backup-manager.rs | 6 +++--- src/tape/test/inventory.rs | 12 ++++++------ tests/worker-task-abort.rs | 2 +- 12 files changed, 24 insertions(+), 26 deletions(-) diff --git a/pbs-client/src/tools/key_source.rs b/pbs-client/src/tools/key_source.rs index 1b1f7828e..8863ff576 100644 --- a/pbs-client/src/tools/key_source.rs +++ b/pbs-client/src/tools/key_source.rs @@ -475,7 +475,7 @@ fn test_crypto_parameters_handling() -> Result<(), Error> { assert!(crypto_parameters(&json!({"keyfile": invalid_keypath, "crypt-mode": "encrypt"})).is_err()); // now set a default key - unsafe { set_test_encryption_key(Ok(Some(default_key.clone()))); } + unsafe { set_test_encryption_key(Ok(Some(default_key))); } // and repeat @@ -550,7 +550,7 @@ fn test_crypto_parameters_handling() -> Result<(), Error> { // now remove default key again unsafe { set_test_encryption_key(Ok(None)); } // set a default master key - unsafe { set_test_default_master_pubkey(Ok(Some(default_master_key.clone()))); } + unsafe { set_test_default_master_pubkey(Ok(Some(default_master_key))); } // and use an explicit master key assert!(crypto_parameters(&json!({"master-pubkey-file": master_keypath})).is_err()); diff --git a/pbs-config/src/tape_encryption_keys.rs b/pbs-config/src/tape_encryption_keys.rs index c1e688ec3..ccdcdf94c 100644 --- a/pbs-config/src/tape_encryption_keys.rs +++ b/pbs-config/src/tape_encryption_keys.rs @@ -177,7 +177,7 @@ pub fn insert_key(key: [u8;32], key_config: KeyConfig, force: bool) -> Result<() key_map.insert(fingerprint.clone(), item); save_keys(key_map)?; - config_map.insert(fingerprint.clone(), key_config); + config_map.insert(fingerprint, key_config); save_key_configs(config_map)?; Ok(()) diff --git a/proxmox-file-restore/src/block_driver_qemu.rs b/proxmox-file-restore/src/block_driver_qemu.rs index f36832dec..564b1f69e 100644 --- a/proxmox-file-restore/src/block_driver_qemu.rs +++ b/proxmox-file-restore/src/block_driver_qemu.rs @@ -167,7 +167,7 @@ async fn ensure_running(details: &SnapRestoreDetails) -> Result Self { - let mut taskdir = basedir.clone(); + let mut taskdir = basedir; taskdir.push("tasks"); let mut task_lock_fn = taskdir.clone(); @@ -192,7 +192,7 @@ impl WorkerTaskSetup { let dir_opts = self.file_opts.clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o755)); - create_path(&self.taskdir, Some(dir_opts.clone()), Some(dir_opts.clone()))?; + create_path(&self.taskdir, Some(dir_opts.clone()), Some(dir_opts))?; // fixme:??? create_path(pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, None, Some(opts))?; Ok(()) }).map_err(|err: Error| format_err!("unable to create task log dir - {}", err)) diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs index a0baf56bc..fcdb965ca 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs @@ -705,7 +705,7 @@ impl DiskState { return None; } match b.component_string(components.len()) { - Ok(cs) => Some((cs.to_owned(), b.size(components.len()))), + Ok(cs) => Some((cs, b.size(components.len()))), Err(_) => None, } }) diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs index 622a05894..ff97c3e5a 100644 --- a/proxmox-rrd/src/cache.rs +++ b/proxmox-rrd/src/cache.rs @@ -70,8 +70,8 @@ impl RRDCache { .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?; let config = Arc::new(CacheConfig { - basedir: basedir.clone(), - file_options: file_options.clone(), + basedir: basedir, + file_options: file_options, dir_options: dir_options, apply_interval, }); diff --git a/src/api2/access/openid.rs b/src/api2/access/openid.rs index 8c17bb764..9e78a8887 100644 --- a/src/api2/access/openid.rs +++ b/src/api2/access/openid.rs @@ -150,7 +150,7 @@ pub fn openid_login( }; let user_id = Userid::try_from(format!("{}@{}", unique_name, realm))?; - tested_username = Some(unique_name.to_string()); + tested_username = Some(unique_name); if !user_info.is_active_user_id(&user_id) { if config.autocreate.unwrap_or(false) { @@ -246,8 +246,7 @@ fn openid_auth_url( let open_id = openid_authenticator(&config, &redirect_url)?; - let url = open_id.authorize_url(PROXMOX_BACKUP_RUN_DIR_M!(), &realm)? - .to_string(); + let url = open_id.authorize_url(PROXMOX_BACKUP_RUN_DIR_M!(), &realm)?; Ok(url.into()) } diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index a7a99db71..d811fd23a 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -969,7 +969,7 @@ pub fn prune_datastore( auth_id.to_string(), to_stdout, move |worker| crate::server::prune_datastore( - worker.clone(), + worker, auth_id, prune_options, &store, diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index 918f034bc..2a7705b86 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -1179,7 +1179,6 @@ fn restore_chunk_archive<'a>( let mut decoder = ChunkArchiveDecoder::new(reader); - let datastore2 = datastore.clone(); let start_time = std::time::SystemTime::now(); let bytes = Arc::new(std::sync::atomic::AtomicU64::new(0)); let bytes2 = bytes.clone(); @@ -1190,7 +1189,7 @@ fn restore_chunk_archive<'a>( "tape restore chunk writer", 4, move |(chunk, digest): (DataBlob, [u8; 32])| { - let chunk_exists = datastore2.cond_touch_chunk(&digest, false)?; + let chunk_exists = datastore.cond_touch_chunk(&digest, false)?; if !chunk_exists { if verbose { task_log!(worker2, "Insert chunk: {}", hex::encode(&digest)); @@ -1202,7 +1201,7 @@ fn restore_chunk_archive<'a>( chunk.decode(None, Some(&digest))?; // verify digest } - datastore2.insert_chunk(&chunk, &digest)?; + datastore.insert_chunk(&chunk, &digest)?; } else if verbose { task_log!(worker2, "Found existing chunk: {}", hex::encode(&digest)); } diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs index b62b77151..ab2805f33 100644 --- a/src/bin/proxmox-backup-manager.rs +++ b/src/bin/proxmox-backup-manager.rs @@ -421,7 +421,7 @@ async fn run() -> Result<(), Error> { if !avoid_init { let backup_user = pbs_config::backup_user()?; let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid); - proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?; + proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts)?; let mut commando_sock = proxmox_rest_server::CommandSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid); proxmox_rest_server::register_task_control_commands(&mut commando_sock)?; @@ -456,7 +456,7 @@ fn get_remote(param: &HashMap) -> Option { .or_else(|| { if let Some(id) = param.get("id") { if let Ok(job) = get_sync_job(id) { - return Some(job.remote.clone()); + return Some(job.remote); } } None @@ -483,7 +483,7 @@ fn get_remote_store(param: &HashMap) -> Option<(String, String)> let store = param .get("remote-store") .map(|r| r.to_owned()) - .or_else(|| job.map(|job| job.remote_store.clone())); + .or_else(|| job.map(|job| job.remote_store)); if let Some(store) = store { return Some((remote, store)) diff --git a/src/tape/test/inventory.rs b/src/tape/test/inventory.rs index 10179d5da..1bc25226b 100644 --- a/src/tape/test/inventory.rs +++ b/src/tape/test/inventory.rs @@ -109,8 +109,8 @@ fn test_media_set_simple() -> Result<(), Error> { let tape1_uuid = inventory.generate_used_tape("tape1", sl1.clone(), 0); - let tape2_uuid = inventory.generate_used_tape("tape2", sl2.clone(), 0); - let tape3_uuid = inventory.generate_used_tape("tape3", sl3.clone(), 0); + let tape2_uuid = inventory.generate_used_tape("tape2", sl2, 0); + let tape3_uuid = inventory.generate_used_tape("tape3", sl3, 0); // generate incomplete media set in pool p2 let sl4 = MediaSetLabel::with_data("p2", Uuid::generate(), 1, ctime + 40, None); @@ -134,9 +134,9 @@ fn test_media_set_simple() -> Result<(), Error> { let media_list = media_set.media_list(); assert_eq!(media_list.len(), 3); - assert_eq!(media_list[0], Some(tape1_uuid.clone())); - assert_eq!(media_list[1], Some(tape2_uuid.clone())); - assert_eq!(media_list[2], Some(tape3_uuid.clone())); + assert_eq!(media_list[0], Some(tape1_uuid)); + assert_eq!(media_list[1], Some(tape2_uuid)); + assert_eq!(media_list[2], Some(tape3_uuid)); // test media set start time assert_eq!(inventory.media_set_start_time(&sl1.uuid), Some(ctime + 10)); @@ -150,7 +150,7 @@ fn test_media_set_simple() -> Result<(), Error> { assert_eq!(media_list.len(), 2); assert_eq!(media_list[0], None); - assert_eq!(media_list[1], Some(tape4_uuid.clone())); + assert_eq!(media_list[1], Some(tape4_uuid)); // start time for incomplete set must be None assert_eq!(inventory.media_set_start_time(&sl4.uuid), None); diff --git a/tests/worker-task-abort.rs b/tests/worker-task-abort.rs index 7ebad1648..b29d047c1 100644 --- a/tests/worker-task-abort.rs +++ b/tests/worker-task-abort.rs @@ -38,7 +38,7 @@ fn worker_task_abort() -> Result<(), Error> { let gid = nix::unistd::Gid::current(); let file_opts = CreateOptions::new().owner(uid).group(gid); - proxmox_rest_server::init_worker_tasks("./target/tasklogtestdir".into(), file_opts.clone())?; + proxmox_rest_server::init_worker_tasks("./target/tasklogtestdir".into(), file_opts)?; use std::sync::{Arc, Mutex};