summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-07-21 10:41:08 +0800
committerSebastian Thiel <sthiel@thoughtworks.com>2019-07-21 10:48:09 +0800
commiteb015d38cbe01ff6b04855ad94936cd8f59be4bc (patch)
tree040d84848bae492ec3348f301ddce96c34ff464b
parent978ddbae31a3769162cfb0fb1b6c95d96701d774 (diff)
Show broken symlinks on the first level of iteration
-rw-r--r--README.md6
-rw-r--r--src/interactive/app/handlers.rs9
-rw-r--r--src/main.rs1
-rw-r--r--src/traverse.rs13
4 files changed, 22 insertions, 7 deletions
diff --git a/README.md b/README.md
index 17ee062..b83b638 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,12 @@ dua interactive
* [ ] Evaluate unit coloring - can we highlight different units better, make them stick out?
+#### ✅ v2.1.9 - improved handling of broken symlinks
+
+* during symlink deletion, now broken symlinks will be deleted as expected.
+* always return to the previous terminal screen so the TUI doesn't stick to the current one.
+* display broken symlinks on the first level of iteration.
+
#### ✅ v2.1.8 - don't follow symbolic links when deleting directories
[A critical bug was discovered](https://github.com/Byron/dua-cli/issues/24) which would lead to deletion
diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs
index 7f84809..9a0f7f6 100644
--- a/src/interactive/app/handlers.rs
+++ b/src/interactive/app/handlers.rs
@@ -94,7 +94,7 @@ impl TerminalApp {
.state
.bookmarks
.get(&parent_idx)
- .map(|v| *v)
+ .copied()
.or_else(|| self.state.entries.get(0).map(|b| b.index));
}
None => self.state.message = Some("Top level reached".into()),
@@ -199,13 +199,14 @@ impl TerminalApp {
}
self.state.entries =
sorted_entries(&self.traversal.tree, self.state.root, self.state.sorting);
- if let None = self.traversal.tree.node_weight(self.state.root) {
+ if self.traversal.tree.node_weight(self.state.root).is_none() {
self.set_root(self.traversal.root_index);
}
- if let None = self
+ if self
.state
.selected
.and_then(|selected| self.state.entries.iter().find(|e| e.index == selected))
+ .is_none()
{
self.state.selected = self.state.entries.get(0).map(|e| e.index);
}
@@ -325,7 +326,7 @@ fn delete_directory_recursively(path: PathBuf) -> Result<(), usize> {
num_errors += into_error_count(fs::remove_file(path));
continue;
}
- Err(e) => {
+ Err(_) => {
num_errors += 1;
continue;
}
diff --git a/src/main.rs b/src/main.rs
index 7fd9867..e5453c7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
+#![allow(clippy::match_bool)]
extern crate failure;
extern crate failure_tools;
extern crate structopt;
diff --git a/src/traverse.rs b/src/traverse.rs
index 5665bff..b4071d4 100644
--- a/src/traverse.rs
+++ b/src/traverse.rs
@@ -71,14 +71,13 @@ impl Traversal {
const INITIAL_CHECK_INTERVAL: usize = 500;
let mut check_instant_every = INITIAL_CHECK_INTERVAL;
- let mut last_seen_eid;
if walk_options.threads == 0 {
// avoid using the global rayon pool, as it will keep a lot of threads alive after we are done.
// Also means that we will spin up a bunch of threads per root path, instead of reusing them.
walk_options.threads = num_cpus::get_physical();
}
for path in input.into_iter() {
- last_seen_eid = 0;
+ let mut last_seen_eid = 0;
for (eid, entry) in walk_options
.iter_from_path(path.as_ref())
.into_iter()
@@ -142,7 +141,15 @@ impl Traversal {
previous_node_idx = entry_index;
previous_depth = entry.depth;
}
- Err(_) => t.io_errors += 1,
+ Err(_) => {
+ if previous_depth == 0 {
+ data.name = path.clone().into();
+ let entry_index = t.tree.add_node(data);
+ t.tree.add_edge(parent_node_idx, entry_index, ());
+ }
+
+ t.io_errors += 1
+ }
}
if eid != 0