From 78fcdec05a707be21a579b70e8d46075b999c0b0 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 30 Dec 2021 22:49:33 -0600 Subject: [PATCH] Add some info statements --- src/ops/put.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/ops/put.rs b/src/ops/put.rs index dd7b4ed..c2d8026 100644 --- a/src/ops/put.rs +++ b/src/ops/put.rs @@ -136,6 +136,7 @@ impl DeletionStrategy { // first, are we on the home mount? if target_mount == *HOME_MOUNT { + info!("Picking strategy MoveTo because target {:?} was on the home mount.", target); return Ok(DeletionStrategy::MoveTo(TrashDir::get_home_trash())); } @@ -234,15 +235,6 @@ impl DeletionStrategy { None => return Err(Error::Put(PutError::InvalidFilename)), }; let file_name = concat_os_str!(elapsed_str, ".", target_file); - // { - // let buf = vec![0; elapsed_str.len() + 1 + target_file.len()]; - // unimplemented!() - // // format!( - // // "{}.{}", - // // elapsed, - // // target.file_name().unwrap().to_str().unwrap() - // // ) - // }; let trash_file_path = trash_dir.files_dir()?.join(&file_name); let trash_info_path = trash_dir @@ -286,19 +278,29 @@ fn should_use_topdir_trash(mount: impl AsRef) -> bool { return false; } - let dir = match File::open(trash_dir) { + let dir = match File::open(&trash_dir) { Ok(file) => file, - Err(_) => return false, + Err(err) => { + info!("Error opening topdir {:?}: {:?}", trash_dir, err); + return false; + } }; let meta = match dir.metadata() { Ok(meta) => meta, - Err(_) => return false, + Err(err) => { + info!( + "Error getting topdir metadata for {:?}: {:?}", + trash_dir, err + ); + return false; + } }; if meta.file_type().is_symlink() { + info!("Trashdir {:?} is a symlink.", trash_dir); return false; } - let perms = meta.permissions(); + let perms = meta.permissions(); perms.mode() & 0o1000 > 0 }