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]]
|
[[package]]
|
||||||
name = "garbage"
|
name = "garbage"
|
||||||
version = "0.2.0-rc3"
|
version = "0.2.0-rc4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "garbage"
|
name = "garbage"
|
||||||
version = "0.2.0-rc3"
|
version = "0.2.0-rc4"
|
||||||
authors = ["Michael Zhang <iptq@protonmail.com>"]
|
authors = ["Michael Zhang <iptq@protonmail.com>"]
|
||||||
description = "cli tool for interacting with the freedesktop trashcan"
|
description = "cli tool for interacting with the freedesktop trashcan"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -13,9 +13,6 @@ use crate::{HOME_MOUNT, MOUNTS};
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("File {0} doesn't exist.")]
|
|
||||||
FileDoesntExist(PathBuf),
|
|
||||||
|
|
||||||
#[error("Refusing to remove directory {0} without '-r' option")]
|
#[error("Refusing to remove directory {0} without '-r' option")]
|
||||||
MissingRecursiveOption(PathBuf),
|
MissingRecursiveOption(PathBuf),
|
||||||
|
|
||||||
|
@ -26,6 +23,7 @@ pub enum Error {
|
||||||
CancelledByUser,
|
CancelledByUser,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Options to pass to put
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
pub struct PutOptions {
|
pub struct PutOptions {
|
||||||
/// The target path to be trashed
|
/// The target path to be trashed
|
||||||
|
@ -157,11 +155,6 @@ impl DeletionStrategy {
|
||||||
// this will be None if target isn't a symlink
|
// this will be None if target isn't a symlink
|
||||||
let link_info = target.read_link().ok();
|
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
|
// file is a directory
|
||||||
if !link_info.is_some() && target.is_dir() && !options.recursive {
|
if !link_info.is_some() && target.is_dir() && !options.recursive {
|
||||||
bail!(Error::MissingRecursiveOption(target.to_path_buf()));
|
bail!(Error::MissingRecursiveOption(target.to_path_buf()));
|
||||||
|
|
Loading…
Reference in a new issue