Don't check for existence

This commit is contained in:
Michael Zhang 2020-04-07 11:47:48 -05:00
parent e3e065d5b7
commit bfd6d55d2c
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
3 changed files with 3 additions and 10 deletions

2
Cargo.lock generated
View file

@ -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)",

View file

@ -1,6 +1,6 @@
[package]
name = "garbage"
version = "0.2.0-rc3"
version = "0.2.0-rc4"
authors = ["Michael Zhang <iptq@protonmail.com>"]
description = "cli tool for interacting with the freedesktop trashcan"
license = "MIT"

View file

@ -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()));