diff --git a/pbs-datastore/examples/ls-snapshots.rs b/pbs-datastore/examples/ls-snapshots.rs index 87f6aa4a..254a3453 100644 --- a/pbs-datastore/examples/ls-snapshots.rs +++ b/pbs-datastore/examples/ls-snapshots.rs @@ -5,11 +5,11 @@ use anyhow::{bail, Error}; use pbs_datastore::DataStore; fn run() -> Result<(), Error> { - let base: PathBuf = match std::env::args().skip(1).next() { + let base: PathBuf = match std::env::args().nth(1) { Some(path) => path.into(), None => bail!("no path passed!\n\nusage: ls-snapshots []"), }; - let max_depth: Option = match std::env::args().skip(2).next() { + let max_depth: Option = match std::env::args().nth(2) { Some(depth) => match depth.parse::() { Ok(depth) if depth < 8 => Some(depth), Ok(_) => bail!("max-depth must be < 8"), diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs index 5440cdb3..35ab0608 100644 --- a/pbs-datastore/src/backup_info.rs +++ b/pbs-datastore/src/backup_info.rs @@ -227,7 +227,7 @@ impl BackupGroup { /// Set the backup owner. pub fn set_owner(&self, auth_id: &Authid, force: bool) -> Result<(), Error> { self.store - .set_owner(&self.ns, &self.as_ref(), auth_id, force) + .set_owner(&self.ns, self.as_ref(), auth_id, force) } } @@ -572,7 +572,7 @@ impl From<&BackupDir> for pbs_api_types::BackupGroup { impl From for pbs_api_types::BackupGroup { fn from(dir: BackupDir) -> pbs_api_types::BackupGroup { - dir.dir.group.into() + dir.dir.group } } diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 148cf5db..d745be39 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -394,7 +394,7 @@ impl DataStore { // construct ns before mkdir to enforce max-depth and name validity let ns = BackupNamespace::from_parent_ns(parent, name)?; - let mut ns_full_path = self.base_path().to_owned(); + let mut ns_full_path = self.base_path(); ns_full_path.push(ns.path()); std::fs::create_dir_all(ns_full_path)?; @@ -404,7 +404,7 @@ impl DataStore { /// Returns if the given namespace exists on the datastore pub fn namespace_exists(&self, ns: &BackupNamespace) -> bool { - let mut path = self.base_path().to_owned(); + let mut path = self.base_path(); path.push(ns.path()); path.exists() } @@ -704,7 +704,7 @@ impl DataStore { ) -> Result + 'static, Error> { let this = Arc::clone(self); Ok( - ListNamespaces::new(Arc::clone(&self), ns)?.filter_map(move |ns| match ns { + ListNamespaces::new(Arc::clone(self), ns)?.filter_map(move |ns| match ns { Ok(ns) => Some(ns), Err(err) => { log::error!("list groups error on datastore {} - {}", this.name(), err); @@ -736,9 +736,9 @@ impl DataStore { ) -> Result + 'static, Error> { let this = Arc::clone(self); Ok(if let Some(depth) = max_depth { - ListNamespacesRecursive::new_max_depth(Arc::clone(&self), ns, depth)? + ListNamespacesRecursive::new_max_depth(Arc::clone(self), ns, depth)? } else { - ListNamespacesRecursive::new(Arc::clone(&self), ns)? + ListNamespacesRecursive::new(Arc::clone(self), ns)? } .filter_map(move |ns| match ns { Ok(ns) => Some(ns), @@ -770,7 +770,7 @@ impl DataStore { ) -> Result + 'static, Error> { let this = Arc::clone(self); Ok( - ListGroups::new(Arc::clone(&self), ns)?.filter_map(move |group| match group { + ListGroups::new(Arc::clone(self), ns)?.filter_map(move |group| match group { Ok(group) => Some(group), Err(err) => { log::error!("list groups error on datastore {} - {}", this.name(), err); @@ -865,11 +865,10 @@ impl DataStore { worker.fail_on_shutdown()?; let digest = index.index_digest(pos).unwrap(); if !self.inner.chunk_store.cond_touch_chunk(digest, false)? { + let hex = hex::encode(digest); task_warn!( worker, - "warning: unable to access non-existent chunk {}, required by {:?}", - hex::encode(digest), - file_name, + "warning: unable to access non-existent chunk {hex}, required by {file_name:?}" ); // touch any corresponding .bad files to keep them around, meaning if a chunk is @@ -1194,7 +1193,7 @@ impl DataStore { ns: BackupNamespace, group: pbs_api_types::BackupGroup, ) -> BackupGroup { - BackupGroup::new(Arc::clone(&self), ns, group) + BackupGroup::new(Arc::clone(self), ns, group) } /// Open a backup group from this datastore. diff --git a/pbs-datastore/src/manifest.rs b/pbs-datastore/src/manifest.rs index 9e356c2b..48a6992a 100644 --- a/pbs-datastore/src/manifest.rs +++ b/pbs-datastore/src/manifest.rs @@ -86,7 +86,7 @@ impl BackupManifest { pub fn new(snapshot: pbs_api_types::BackupDir) -> Self { Self { backup_type: snapshot.group.ty, - backup_id: snapshot.group.id.into(), + backup_id: snapshot.group.id, backup_time: snapshot.time, files: Vec::new(), unprotected: json!({}),