diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-03-27 21:26:23 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-03-27 21:26:23 +0800 |
commit | 768cbce3963be7d6ece448d56289223810d678ac (patch) | |
tree | f56cb2355ad058c7a228b70505ffd1eb440698c7 | |
parent | 2bbbb0b42371e0701af3b927fee129cd8be5a852 (diff) |
Truly don't follow symlinks unless they are the only top-level path.v2.3.9
This is a brute-force hack which won't show them at all, there certainly
is better ways if we would know if we expanded paths ourselves or not.
-rw-r--r-- | CHANGELOG.md | 55 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/aggregate.rs | 10 | ||||
-rw-r--r-- | src/traverse.rs | 21 |
5 files changed, 56 insertions, 34 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c1825f..dfa881e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,63 +1,68 @@ -#### ✅ v2.3.8 `dua interactive` (`dua i`) is now about twice as fast due to using all logical cores, not just physical ones +#### v2.3.9 Do not follow symlinks unless it's the only root path to follow + +This brutally fixes an issue where symbolics links are honored when they are placed in the current working directory, as internally `dua` will +treat each cwd directory entry as individual root path. + +#### v2.3.8 `dua interactive` (`dua i`) is now about twice as fast due to using all logical cores, not just physical ones This is also the first release with github releases: https://github.com/Byron/dua-cli/releases/tag/v2.3.8 -#### ✅ v2.3.7 Upgrade to filesize 0.2.0 from 0.1.0; update dependency versions +#### v2.3.7 Upgrade to filesize 0.2.0 from 0.1.0; update dependency versions -#### ✅ v2.3.6 Upgrade to jwalk 0.5 bringing better threading control and no symlink following during traversal +#### v2.3.6 Upgrade to jwalk 0.5 bringing better threading control and no symlink following during traversal -#### ✅ v2.3.5 Fast exit from interactive mode for a responsive exit; dependency updates (except jwalk) +#### v2.3.5 Fast exit from interactive mode for a responsive exit; dependency updates (except jwalk) -#### ✅ v2.3.4 YANKED - jwalk 0.5.0 wasn't used correctly which led to a performance regression +#### v2.3.4 YANKED - jwalk 0.5.0 wasn't used correctly which led to a performance regression -#### ✅ v2.3.3 YANKED - journey tests failed to changed method signature +#### v2.3.3 YANKED - journey tests failed to changed method signature -#### ✅ v2.3.2 Incude the license file in crate +#### v2.3.2 Incude the license file in crate -#### ✅ v2.3.1 Include .md files in Crate, update dependencies +#### v2.3.1 Include .md files in Crate, update dependencies -#### ✅ v2.3 Show size on disk by default; Dependency Update +#### v2.3 Show size on disk by default; Dependency Update Thanks to [this PR](https://github.com/Byron/dua-cli/pull/37), hard links are now not counted anymore. The `-l` flag will count hard links as it did before. And of course, this has no noticable performance impact. -#### ✅ v2.2 Show size on disk by default; Dependency Update +#### v2.2 Show size on disk by default; Dependency Update Thanks to [this PR](https://github.com/Byron/dua-cli/pull/35), the old apparent size can be displayed with the `-A` flag, and the much more useful 'size on disk' is now shown by default. To my pleasant surprise, this does not seem to affect performance at all - everything stays speedy. -#### ✅ v2.1.13-- Dependency Update; Github Releases +#### v2.1.13-- Dependency Update; Github Releases Binaries for Linux and MacOS are now available on GitHub Releases. -#### ✅ v2.1.12-- More obvious highlighting of active panel +#### v2.1.12-- More obvious highlighting of active panel Depending on the terminal used, it might not have been obvious which panel was active. This might be confusing to new and current users. Now the color of the widget frame is changed to light gray, instead of remaining gray. -#### ✅ v2.1.11 - Finally fix symlink handling +#### v2.1.11 - Finally fix symlink handling `dua` will not follow symbolic links when deleting directories. Thank a ton, @vks! _Technical Notes_: Handling symbolic links properly is impossible without usage of `symlink_metadata()`. -#### ✅ v2.1.10 - compatibility with light terminals +#### v2.1.10 - compatibility with light terminals * the TUI is now usable on light terminals, and highlighting is more consistent. Thank you, @vks! * Fixes misaligned columns when displaying '100.00%' alongside other rows by displaying `100.0%` instead. Thanks, @vks, for pointing it out. -#### ✅ v2.1.9 - improved handling of broken symlinks +#### 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 +#### 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 of unwanted `directories` as `dua` would follow symbolic links during traversal during deletion. @@ -66,38 +71,38 @@ Please note that symbolic links to files would be treated correctly, only removi This is now fixed. -#### ✅ v2.1.7 - use latest version of open-rs +#### v2.1.7 - use latest version of open-rs That way, pressing `shift + O` to open the currently selected file won't possibly spam the terminal with messages caused by the program used to find the system program to open the file. Fixes [#14](https://github.com/Byron/dua-cli/issues/14) -#### ✅ v2.1.5 - re-release with Cargo.lock +#### v2.1.5 - re-release with Cargo.lock -#### ✅ v2.1.2 bug fixes and improvements +#### v2.1.2 bug fixes and improvements * Performance fix when showing folders with large amounts of files * Display of amount of entries per directory -#### ✅ v2.1.1 bug fixes and improvements +#### v2.1.1 bug fixes and improvements * Better information about deletion progress * removal of windows support -#### ✅ v2.1.0- bug fixes and improvements +#### v2.1.0- bug fixes and improvements * windows support (never actually worked), usage of crossterm is difficult thanks to completely different input handling. * additional key-bindings * auto-restore previous selection in each visited directory -#### ✅ v2.0.1- bug fixes and improvements +#### v2.0.1- bug fixes and improvements * fix typo in title * better display of IO-Errors in aggregate mode -#### ✅ v2.0.0 - interactive visualization of directory sizes with an option to queue their deletion +#### v2.0.0 - interactive visualization of directory sizes with an option to queue their deletion A sub-command bringing up a terminal user interface to allow drilling into directories, and clearing them out, all using the keyboard exclusively. @@ -105,11 +110,11 @@ A sub-command bringing up a terminal user interface to allow drilling into direc * [x] Single Unit Mode, see [reddit](https://www.reddit.com/r/rust/comments/bvjtan/introducing_dua_a_parallel_du_for_humans/epsroxg/) -#### ✅v1.2 (_released_) - - the first usable, read-only interactive terminal user interface +#### 1.2 (_released_) - - the first usable, read-only interactive terminal user interface That's that. We also use `tui-react`, something that makes it much more pleasant to handle the application and GUI state. -#### ✅v1.0 (_released_) - aggregate directories, fast +#### 1.0 (_released_) - aggregate directories, fast Simple CLI to list top-level directories similar to sn-sort, but faster and more tailored to getting an idea of where most space is used. @@ -182,7 +182,7 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "dua-cli" -version = "2.3.8" +version = "2.3.9" dependencies = [ "atty", "byte-unit", @@ -1,6 +1,6 @@ [package] name = "dua-cli" -version = "2.3.8" +version = "2.3.9" authors = ["Sebastian Thiel <byronimo@gmail.com>"] edition = "2018" include = ["src/**/*", "Cargo.*", "*.md", "LICENSE"] diff --git a/src/aggregate.rs b/src/aggregate.rs index 101e45b..538950a 100644 --- a/src/aggregate.rs +++ b/src/aggregate.rs @@ -22,7 +22,17 @@ pub fn aggregate( let mut num_roots = 0; let mut aggregates = Vec::new(); let mut inodes = InodeFilter::default(); + let paths: Vec<_> = paths.into_iter().collect(); + let input_len = paths.len(); for path in paths.into_iter() { + // For now, bluntly ignore symlinks that are on the top-level, and there are more roots to follow + if input_len > 1 { + if let Ok(meta) = path.as_ref().symlink_metadata() { + if meta.file_type().is_symlink() { + continue; + } + } + } num_roots += 1; let mut num_bytes = 0u64; let mut num_errors = 0u64; diff --git a/src/traverse.rs b/src/traverse.rs index a332088..c971bd1 100644 --- a/src/traverse.rs +++ b/src/traverse.rs @@ -78,7 +78,16 @@ impl Traversal { // Also means that we will spin up a bunch of threads per root path, instead of reusing them. walk_options.threads = num_cpus::get(); } + let input_len = input.len(); for path in input.into_iter() { + // For now, bluntly ignore symlinks that are on the top-level, and there are more roots to follow + if input_len > 1 { + if let Ok(meta) = path.symlink_metadata() { + if meta.file_type().is_symlink() { + continue; + } + } + } let mut last_seen_eid = 0; for (eid, entry) in walk_options .iter_from_path(path.as_ref()) @@ -102,13 +111,11 @@ impl Traversal { if walk_options.apparent_size { m.len() } else { - data.name.size_on_disk_fast(m).unwrap_or_else( - |_| { - t.io_errors += 1; - data.metadata_io_error = true; - 0 - }, - ) + data.name.size_on_disk_fast(m).unwrap_or_else(|_| { + t.io_errors += 1; + data.metadata_io_error = true; + 0 + }) } } Some(Ok(_)) => 0, |