diff --git a/Cargo.lock b/Cargo.lock index eae9a2c..7943340 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,7 +69,7 @@ dependencies = [ [[package]] name = "garbage" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index ba796ba..a9d0914 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garbage" -version = "0.2.0" +version = "0.2.1" authors = ["Michael Zhang "] description = "cli tool for interacting with the freedesktop trashcan" license = "MIT" diff --git a/src/info.rs b/src/info.rs index ceeed5c..7fb09f7 100644 --- a/src/info.rs +++ b/src/info.rs @@ -5,7 +5,7 @@ use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf}; use chrono::{DateTime, Local, TimeZone}; -use percent_encoding::{percent_decode, }; +use percent_encoding::percent_decode; use crate::errors::{Error, TrashInfoError}; use crate::utils; @@ -107,11 +107,7 @@ impl TrashInfo { /// Write the current TrashInfo into a .trashinfo file. pub fn write(&self, mut out: impl Write) -> Result<(), io::Error> { writeln!(out, "[Trash Info]")?; - writeln!( - out, - "Path={}", - utils::percent_encode(&self.path) - )?; + writeln!(out, "Path={}", utils::percent_encode(&self.path))?; writeln!( out, "DeletionDate={}", diff --git a/src/ops/list.rs b/src/ops/list.rs index 322d8c0..d841ede 100644 --- a/src/ops/list.rs +++ b/src/ops/list.rs @@ -2,8 +2,8 @@ use std::path::PathBuf; use anyhow::Result; -use crate::TrashDir; use crate::utils; +use crate::TrashDir; /// Options to pass to list #[derive(StructOpt)] @@ -31,7 +31,11 @@ pub fn list(options: ListOptions) -> Result<()> { .collect::>(); files.sort_unstable_by_key(|info| info.deletion_date); for info in files { - println!("{}\t{}", info.deletion_date, utils::percent_encode(info.path)); + println!( + "{}\t{}", + info.deletion_date, + utils::percent_encode(info.path) + ); } Ok(()) diff --git a/src/ops/put.rs b/src/ops/put.rs index 8a7e982..a45bdbc 100644 --- a/src/ops/put.rs +++ b/src/ops/put.rs @@ -15,7 +15,6 @@ use crate::{HOME_MOUNT, MOUNTS}; pub enum Error { // #[error("Refusing to remove directory {0} without '-r' option")] // MissingRecursiveOption(PathBuf), - #[error("Refusing to remove '.' or '..', skipping...")] CannotTrashDotDirs, diff --git a/src/ops/restore.rs b/src/ops/restore.rs index 4559434..5b7e873 100644 --- a/src/ops/restore.rs +++ b/src/ops/restore.rs @@ -4,8 +4,8 @@ use std::path::PathBuf; use anyhow::Result; -use crate::TrashDir; use crate::utils; +use crate::TrashDir; /// Options to pass to restore #[derive(StructOpt)] diff --git a/src/utils.rs b/src/utils.rs index 12f78ed..ccd62c4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,7 +5,7 @@ use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf, MAIN_SEPARATOR}; use anyhow::Result; -use percent_encoding::{AsciiSet}; +use percent_encoding::AsciiSet; use walkdir::WalkDir; const MASK: &AsciiSet = percent_encoding::CONTROLS; @@ -59,9 +59,7 @@ pub fn recursive_copy(src: impl AsRef, dst: impl AsRef) -> Result<() pub fn percent_encode(path: impl AsRef) -> String { let path = path.as_ref(); path.iter() - .map(|segment| { - percent_encoding::percent_encode(segment.as_bytes(), MASK).to_string() - }) + .map(|segment| percent_encoding::percent_encode(segment.as_bytes(), MASK).to_string()) .collect::>() .join(&MAIN_SEPARATOR.to_string()) }