From e421db40136e71042f4513bdceb313d8ad7a6f29 Mon Sep 17 00:00:00 2001 From: Eduard Tolosa Date: Sun, 20 Apr 2025 14:50:52 -0500 Subject: [PATCH] Clippy fixes --- src/args.rs | 4 ++-- src/database.rs | 2 +- src/operations.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/args.rs b/src/args.rs index d15cfba..e15537d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -23,7 +23,7 @@ pub struct Args { /// Snapshot id or name to work with. #[clap(long = "id", default_value = "")] pub snapshot_id: String, - /// Path to the SQLite database file. + /// Path to the `SQLite` database file. #[clap( short = 'd', long = "dfile", @@ -40,7 +40,7 @@ pub struct Args { /// Keep only the last X items. #[clap(short = 'k', long = "keep", default_value = "10")] pub keep_only: usize, - /// Time in milliseconds until SQLite can return a timeout. Do not touch if you don't know what you are doing. + /// Time in milliseconds until `SQLite` can return a timeout. Do not touch if you don't know what you are doing. #[clap(long = "timeout", default_value = "5000")] pub timeout: usize, /// Create a read-only/ro snapshot. diff --git a/src/database.rs b/src/database.rs index 14d8de9..4987b58 100644 --- a/src/database.rs +++ b/src/database.rs @@ -65,7 +65,7 @@ pub fn return_all_data(connection: &Connection) -> Result> { pub fn return_only_x_items(connection: &Connection, args: &Args) -> Result> { let mut snapshots_data: Vec = Vec::new(); - let mut statement = connection.prepare(&format!("SELECT name,snap_id,kind,source,destination,machine,ro_rw,date FROM (SELECT row_number() over(ORDER BY date DESC) n,* from snapshots WHERE name like '{}%' AND kind = '{}' AND ro_rw = '{}') WHERE n > {}", args.snapshot_prefix, args.snapshot_kind, args.read_write, args.keep_only))?; + let mut statement = connection.prepare(format!("SELECT name,snap_id,kind,source,destination,machine,ro_rw,date FROM (SELECT row_number() over(ORDER BY date DESC) n,* from snapshots WHERE name like '{}%' AND kind = '{}' AND ro_rw = '{}') WHERE n > {}", args.snapshot_prefix, args.snapshot_kind, args.read_write, args.keep_only))?; while statement.next()? == State::Row { let db_struct = Database::default(); diff --git a/src/operations.rs b/src/operations.rs index 4e4b66c..6db1448 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -41,7 +41,7 @@ pub fn del_snapshot(snapshot_name: &str) -> bool { pub fn restore_snapshot(args: &Args, snapshot_name: &str) -> bool { !Path::new(&args.dest_dir).exists() && Command::new("btrfs") - .args(["subvolume", "snapshot", &snapshot_name, &args.dest_dir]) + .args(["subvolume", "snapshot", snapshot_name, &args.dest_dir]) .status() .expect("Error restoring the snapshot.") .success()