summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-04-19 18:44:39 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-04-19 18:44:39 -0400
commit5ddbb6a3469b86177e59680c111323f5ca7ecc29 (patch)
tree89f0f6c54c11915384f2cfd03ce6f848743c8d39
parent74a38d8c0dc929ebe8e565fd685d015f5be2df3f (diff)
fix issue when a cut does not remove the original folder
-rw-r--r--src/commands/file_operations.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/commands/file_operations.rs b/src/commands/file_operations.rs
index 0db7f41..f93d8b4 100644
--- a/src/commands/file_operations.rs
+++ b/src/commands/file_operations.rs
@@ -296,14 +296,14 @@ fn fs_cut_thread(
Err(_) => {
if path.symlink_metadata()?.is_dir() {
std::fs::create_dir(&destination)?;
- let path: Vec<path::PathBuf> = std::fs::read_dir(path)?
+ let cpath: Vec<path::PathBuf> = std::fs::read_dir(&path)?
.filter_map(|s| match s {
Ok(s) => Some(s.path()),
_ => None,
})
.collect();
- match fs_extra::move_items(&path, &destination, &options) {
+ match fs_extra::move_items(&cpath, &destination, &options) {
Err(e) => {
let err =
std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e));
@@ -311,6 +311,7 @@ fn fs_cut_thread(
}
_ => {}
}
+ std::fs::remove_dir_all(&path)?;
} else {
std::fs::copy(&path, &destination)?;
std::fs::remove_file(&path)?;