Don't check for existence
This commit is contained in:
parent
e3e065d5b7
commit
bfd6d55d2c
3 changed files with 3 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -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)",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()));
|
||||
|
|
Loading…
Reference in a new issue