datastore: clippy fixes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-15 16:01:09 +02:00
parent 118e984996
commit ca3f8757ba
4 changed files with 14 additions and 15 deletions

View File

@ -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 <path> [<max-depth>]"),
};
let max_depth: Option<usize> = match std::env::args().skip(2).next() {
let max_depth: Option<usize> = match std::env::args().nth(2) {
Some(depth) => match depth.parse::<usize>() {
Ok(depth) if depth < 8 => Some(depth),
Ok(_) => bail!("max-depth must be < 8"),

View File

@ -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<BackupDir> for pbs_api_types::BackupGroup {
fn from(dir: BackupDir) -> pbs_api_types::BackupGroup {
dir.dir.group.into()
dir.dir.group
}
}

View File

@ -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<impl Iterator<Item = BackupNamespace> + '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<impl Iterator<Item = BackupNamespace> + '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<impl Iterator<Item = BackupGroup> + '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.

View File

@ -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!({}),