From bfd6d55d2c3296e37c3be07fbd1f41fb227ff19e Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Tue, 7 Apr 2020 11:47:48 -0500 Subject: [PATCH] Don't check for existence --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/ops/put.rs | 9 +-------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b35afcf..9f2bf7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,7 +69,7 @@ dependencies = [ [[package]] name = "garbage" -version = "0.2.0-rc3" +version = "0.2.0-rc4" 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 0a08c10..456ebc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garbage" -version = "0.2.0-rc3" +version = "0.2.0-rc4" authors = ["Michael Zhang "] description = "cli tool for interacting with the freedesktop trashcan" license = "MIT" diff --git a/src/ops/put.rs b/src/ops/put.rs index 2c722e7..74d6226 100644 --- a/src/ops/put.rs +++ b/src/ops/put.rs @@ -13,9 +13,6 @@ use crate::{HOME_MOUNT, MOUNTS}; #[derive(Debug, Error)] pub enum Error { - #[error("File {0} doesn't exist.")] - FileDoesntExist(PathBuf), - #[error("Refusing to remove directory {0} without '-r' option")] MissingRecursiveOption(PathBuf), @@ -26,6 +23,7 @@ pub enum Error { CancelledByUser, } +/// Options to pass to put #[derive(StructOpt)] pub struct PutOptions { /// The target path to be trashed @@ -157,11 +155,6 @@ impl DeletionStrategy { // this will be None if target isn't a symlink let link_info = target.read_link().ok(); - // file doesn't exist - if !target.exists() { - bail!(Error::FileDoesntExist(target.to_path_buf())); - } - // file is a directory if !link_info.is_some() && target.is_dir() && !options.recursive { bail!(Error::MissingRecursiveOption(target.to_path_buf()));