Apply clippy fixes.

This commit is contained in:
Eduard Tolosa 2024-02-05 11:48:39 -05:00
parent df68951767
commit 933c780ccc

View file

@ -1,12 +1,13 @@
use crate::utils::is_same_character;
use std::path::PathBuf;
use { use {
crate::args::Args, crate::{args::Args, utils::is_same_character},
anyhow::Result, anyhow::Result,
std::{path::Path, process::Command}, std::{
path::{Path, PathBuf},
process::Command,
},
}; };
#[must_use]
pub fn take_snapshot(args: &Args, snapshot_name: &str) -> bool { pub fn take_snapshot(args: &Args, snapshot_name: &str) -> bool {
let snapshot_name = format!("{}/{}", args.dest_dir, snapshot_name); let snapshot_name = format!("{}/{}", args.dest_dir, snapshot_name);
let mut btrfs_args = vec!["subvolume", "snapshot", &args.source_dir, &snapshot_name]; let mut btrfs_args = vec!["subvolume", "snapshot", &args.source_dir, &snapshot_name];
@ -20,12 +21,12 @@ pub fn take_snapshot(args: &Args, snapshot_name: &str) -> bool {
.success() .success()
} }
#[must_use]
pub fn del_snapshot(snapshot_name: &str) -> bool { pub fn del_snapshot(snapshot_name: &str) -> bool {
// Refuse to delete the root subvolume. // Refuse to delete the root subvolume.
if snapshot_name == "/" || is_same_character(snapshot_name, '/') { if snapshot_name == "/" || is_same_character(snapshot_name, '/') {
println!( println!(
"Snapshot name to delete is: {}. Refusing to delete the root subvolume.", "Snapshot name to delete is: {snapshot_name}. Refusing to delete the root subvolume."
snapshot_name
); );
std::process::exit(1); std::process::exit(1);
} }
@ -36,6 +37,7 @@ pub fn del_snapshot(snapshot_name: &str) -> bool {
.success() .success()
} }
#[must_use]
pub fn restore_snapshot(args: &Args, snapshot_name: &str) -> bool { pub fn restore_snapshot(args: &Args, snapshot_name: &str) -> bool {
!Path::new(&args.dest_dir).exists() !Path::new(&args.dest_dir).exists()
&& Command::new("btrfs") && Command::new("btrfs")