Giter VIP home page Giter VIP logo

dua-cli's Introduction

Rust Crates.io Packaging status

dua (-> Disk Usage Analyzer) is a tool to conveniently learn about the usage of disk space of a given directory. It's parallel by default and will max out your SSD, providing relevant information as fast as possible. Optionally delete superfluous data, and do so more quickly than rm.

asciicast

Installation

Binary Release

MacOS

curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | \
    sh -s -- --git Byron/dua-cli --crate dua --tag v2.17.4

MacOS via MacPorts:

sudo port selfupdate
sudo port install dua-cli

MacOS via Homebrew

brew update
brew install dua-cli

Linux

Linux requires the target to be specified explicitly to obtain the MUSL build.

curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | \
    sh -s -- --git Byron/dua-cli --target x86_64-unknown-linux-musl --crate dua --tag v2.17.4

Windows via Scoop

scoop install dua

Pre-built Binaries

See the releases section for manual installation of a binary, pre-built for many platforms.

Cargo

Via cargo, which can be obtained using rustup

For Unix

cargo install dua-cli

# And if you don't need a terminal user interface (most compatible)
cargo install dua-cli --no-default-features

# Compiles on most platforms, with terminal user interface
cargo install dua-cli --no-default-features --features tui-crossplatform

For Windows, nightly features are currently required.

cargo +nightly install dua-cli

VoidLinux

Via xbps on your VoidLinux system.

xbps-install dua-cli

Fedora

Via dnf on your Fedora system.

sudo dnf install dua-cli

Arch Linux

Via pacman on your ArchLinux system.

sudo pacman -S dua-cli

NixOS

https://search.nixos.org/packages?channel=23.11&show=dua&from=0&size=50&sort=relevance&type=packages&query=dua

Nix-shell (temporary)

nix-shell -p dua

NixOS configuration

  environment.systemPackages = [
    pkgs.dua
  ];

NetBSD

Via pkgin on your NetBSD system.

pkgin install dua-cli

Or, building from source

cd /usr/pkgsrc/sysutils/dua-cli
make install

Windows

You will find pre-built binaries for Windows in the releases section. Alternatively, install via cargo as in

cargo +nightly install dua-cli

Usage

# count the space used in the current working directory
dua
# count the space used in all directories that are not hidden
dua *
# learn about additional functionality
dua aggregate --help

Interactive Mode

Launch into interactive mode with the i or interactive subcommand. Get help on keyboard shortcuts with ?. Use this mode to explore, and/or to delete files and directories to release disk space.

Please note that great care has been taken to prevent accidential deletions due to a multi-stage process, which makes this mode viable for exploration.

dua i
dua interactive

Development

Please note that all the following assumes a unix system. On Windows, the linux subsystem should do the job.

Run tests

make tests

Learn about other targets

make

But why is…

…there only one available backend? termion was available previously.

Maintaining both backends seemed more cumbersome than it's worth and add complexity I didn't like anymore. termion had its benefits, but I never liked that it seems to have dropped out of support. Thus crossterm is the only remaining backend and it's very actively developed.

Acknowledgements

Thanks to jwalk, all there was left to do is to write a command-line interface. As jwalk matures, dua should benefit instantly.

Limitations

  • Does not show symbolic links at all if no path is provided when invoking dua
    • in an effort to skip symbolic links, for now there are pruned and are not used as a root. Symbolic links will be shown if they are not a traversal root, but will not be followed.
  • Interactive mode only looks good in dark terminals (see this issue)
  • easy fix: file names in main window are not truncated if too large. They are cut off on the right.
  • There are plenty of examples in tests/fixtures which don't render correctly in interactive mode. This can be due to graphemes not interpreted correctly. With Chinese characters for instance, column sizes are not correctly computed, leading to certain columns not being shown. In other cases, the terminal gets things wrong - I use alacritty, and with certain characaters it performs worse than, say iTerm3. See https://github.com/minimaxir/big-list-of-naughty-strings/blob/master/blns.txt for the source.
  • In interactive mode, you will need about 60MB of memory for 1 million entries in the graph.
  • In interactive mode, the maximum amount of files is limited to 2^32 - 1 (u32::max_value() - 1) entries.
    • One node is used as to 'virtual' root
    • The actual amount of nodes stored might be lower, as there might be more edges than nodes, which are also limited by a u32 (I guess)
    • The limitation is imposed by the underlying petgraph crate, which declares it as unsafe to use u64 for instance.
    • It's possibly UB when that limit is reached, however, it was never observed either.

Similar Programs

dua-cli's People

Contributors

bobo1239 avatar byron avatar chessmango avatar cinerea0 avatar cosmichorrordev avatar federicostra avatar fmckeogh avatar freaky avatar geezus42 avatar gosuwachu avatar herbygillot avatar ignatenkobrain avatar jackyoustra avatar jcgruenhage avatar kidonng avatar lcook avatar mephistophiles avatar mibac138 avatar murlakatamenka avatar oconnor663 avatar omnikar avatar piotrwach avatar rivy avatar rye avatar tessus avatar tim77 avatar tranzystorekk avatar tsathishkumar avatar unixzii avatar vks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dua-cli's Issues

Integer overflow with huge files

When faced with file sizes that sum beyond the limits of a u64, such as:

.rw-r--r-- 9.2E freaky freaky 29 Jun 21:48 huge1
.rw-r--r-- 9.2E freaky freaky 29 Jun 21:49 huge2
.rw-r--r-- 9.2E freaky freaky 29 Jun 21:49 huge3
.rw-r--r-- 9.2E freaky freaky 29 Jun 21:49 huge4

dua -A in debug mode panics:

thread 'main' panicked at 'attempt to add with overflow', /home/freaky/code/dua-cli-freaky/src/aggregate.rs:60:21

And produces incorrect results in release builds:

  18.45 EB huge

Not really worse than most other similar tools - GNU du just gives up and declares the size infinite, and BSD du seems to believe negative file sizes are possible - but perhaps it would be nice to Just Work, given Rust's u128 support.

Don't use termion for `dua aggregate` coloring on windows

This is already sufficiently abstracted…

dua-cli/src/common.rs

Lines 117 to 145 in b7ed2bb

pub enum Color {
/// Use no color
None,
/// Use terminal colors
Terminal,
}
pub(crate) struct DisplayColor<C> {
kind: Color,
color: C,
}
impl Color {
pub(crate) fn display<C>(self, color: C) -> DisplayColor<C> {
DisplayColor { kind: self, color }
}
}
impl<C> fmt::Display for DisplayColor<C>
where
C: fmt::Display,
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self.kind {
Color::None => Ok(()),
Color::Terminal => self.color.fmt(f),
}
}
}

…which should make it straightforward to use a 'color-crate' that is cross-platform. Maybe it's possible to use that on linux as well, but it's not mandatory as it would also increase compile times.

Related to #2

Provide option for not following symlinks

This just happened today so I think I should bring this up.

Basically there's a folder that contains a ton of trash, but also happened to point to another important folder and I didn't know about that. So when I went ahead and cleaned up the first folder with the interactive mode, it also deletes the second one.

So I wonder if an option can be added so that symlinks are not followed (or even make that the default behaviour) so things like this won't happen to other people as well.

Ignore 'special files' (originally: Ignore the /proc filesystem)

Just ran: dua /. After a while, it printed:

141.02 TB /    <3 IO Error(s)>

...my local disk is not that large. By, uh, several orders of magnitude.

Going to / and running dua:

   0.00  B lost+found
   0.00  B mnt
   0.00  B root
   0.00  B srv
   2.54 KB dev
   3.52 KB .scripts
  85.26 KB run
   1.54 MB tmp
  30.85 MB etc
  81.55 MB boot
 657.30 MB sys
   1.85 GB bin
   1.85 GB sbin
  10.86 GB lib
  10.86 GB lib64
  18.13 GB opt
  19.76 GB usr
 118.48 GB home <1 IO Error(s)>
 130.30 GB var
 140.74 TB proc <2 IO Error(s)>
 141.05 TB total        <3 IO Error(s)>

Seems like /proc is reporting very weird sizes.

By the way, the different between dua / and cd /; dua was surprising, even though correct as per the help message.

Missing Entry highlight in interactive mode on Win10-x86-64-MSVC

When using dua i on windows 10 I noticed that I did not see any highlight on the currently selected item.

I was using dua with Microsoft Terminal + Powershell Core 7. One specific thing I noticed when attempting to run this directly on the Powershell 7 shell is that the currently selected item has a slightly whiter text, but still no selection (inverted color on the current item).

below is a screenshot using the powershell 7 shell
image

The currently selected item is the audioplayback folder. But as you can see its almost completely impossible to distinguish.

other things of note are:

  • having a ? in the beginning of current path on the top.
  • the "capacity" meters next to directory having unrecognized characters (this seems to be a problem with my default terminal font consolas, switching to the new cascadia code font in my terminal fixed this)

Other than these problems, it's a very nice program to use :)

2.3.3 build fails on Fedora

     Running `/usr/bin/rustc --crate-name dua --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C opt-level=3 --test -C metadata=0ead1ce69f69bace -C extra-filename=-0ead1ce69f69bace --out-dir /builddir/build/BUILD/dua-cli-2.3.3/target/release/deps -L dependency=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps --extern atty=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libatty-7ab650f33e255e65.rlib --extern byte_unit=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libbyte_unit-42624cc2036cae21.rlib --extern failure=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libfailure-54e08db737ce28f0.rlib --extern failure_tools=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libfailure_tools-ab5bfbd7d01c5737.rlib --extern filesize=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libfilesize-e5eca7b6ec84907b.rlib --extern itertools=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libitertools-a6ecbcf4956e2494.rlib --extern jwalk=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libjwalk-33125c89b6c104b4.rlib --extern log=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/liblog-c2673a3a8764d8d2.rlib --extern num_cpus=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libnum_cpus-540330b3b6fd3719.rlib --extern open=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libopen-99a9b03245640124.rlib --extern petgraph=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libpetgraph-2b4870a46b520600.rlib --extern pretty_assertions=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libpretty_assertions-e03e860cdfe699c4.rlib --extern structopt=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libstructopt-953ea39fa9ebfd19.rlib --extern termion=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libtermion-8fdc6d3b98684c34.rlib --extern tui=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libtui-0c3680176c266e4e.rlib --extern tui_react=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libtui_react-6211bea35766d921.rlib --extern unicode_segmentation=/builddir/build/BUILD/dua-cli-2.3.3/target/release/deps/libunicode_segmentation-9fede8a1cd057827.rlib -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now -Ccodegen-units=1 --cap-lints=warn -L native=/builddir/build/BUILD/dua-cli-2.3.3/target/release/build/backtrace-sys-65450aba3fc6d909/out`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_readonly.rs:50:28
   |
50 |         app.process_events(&mut terminal, b"s".keys())?;
   |                            ^^^^^^^^^^^^^
   |                            |
   |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
   |                            help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_readonly.rs:62:28
   |
62 |         app.process_events(&mut terminal, b"s".keys())?;
   |                            ^^^^^^^^^^^^^
   |                            |
   |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
   |                            help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_readonly.rs:78:28
   |
78 |         app.process_events(&mut terminal, b"j".keys())?;
   |                            ^^^^^^^^^^^^^
   |                            |
   |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
   |                            help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_readonly.rs:85:28
   |
85 |         app.process_events(&mut terminal, b"j".keys())?;
   |                            ^^^^^^^^^^^^^
   |                            |
   |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
   |                            help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_readonly.rs:92:28
   |
92 |         app.process_events(&mut terminal, b"k".keys())?;
   |                            ^^^^^^^^^^^^^
   |                            |
   |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
   |                            help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_readonly.rs:99:28
   |
99 |         app.process_events(&mut terminal, b"k".keys())?;
   |                            ^^^^^^^^^^^^^
   |                            |
   |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
   |                            help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:106:28
    |
106 |         app.process_events(&mut terminal, b"o".keys())?;
    |                            ^^^^^^^^^^^^^
    |                            |
    |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                            help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:120:32
    |
120 |             app.process_events(&mut terminal, b"u".keys())?;
    |                                ^^^^^^^^^^^^^
    |                                |
    |                                expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                                help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:135:28
    |
135 |         app.process_events(&mut terminal, b"ju".keys())?;
    |                            ^^^^^^^^^^^^^
    |                            |
    |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                            help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:152:28
    |
152 |         app.process_events(&mut terminal, b"k".keys())?;
    |                            ^^^^^^^^^^^^^
    |                            |
    |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                            help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:154:28
    |
154 |         app.process_events(&mut terminal, b"d".keys())?;
    |                            ^^^^^^^^^^^^^
    |                            |
    |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                            help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:176:32
    |
176 |             app.process_events(&mut terminal, b"d".keys())?;
    |                                ^^^^^^^^^^^^^
    |                                |
    |                                expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                                help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:193:32
    |
193 |             app.process_events(&mut terminal, b"d".keys())?;
    |                                ^^^^^^^^^^^^^
    |                                |
    |                                expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                                help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:210:32
    |
210 |             app.process_events(&mut terminal, b"k ".keys())?;
    |                                ^^^^^^^^^^^^^
    |                                |
    |                                expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                                help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:229:28
    |
229 |         app.process_events(&mut terminal, b" j ".keys())?;
    |                            ^^^^^^^^^^^^^
    |                            |
    |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                            help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
   --> src/interactive/app_test/journeys_readonly.rs:243:28
    |
243 |         app.process_events(&mut terminal, b"\t".keys())?;
    |                            ^^^^^^^^^^^^^
    |                            |
    |                            expected struct `tui_react::terminal::Terminal`, found mutable reference
    |                            help: consider removing the borrow: `terminal`
    |
    = note:         expected struct `tui_react::terminal::Terminal<_>`
            found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_with_writes.rs:15:24
   |
15 |     app.process_events(&mut terminal, b"doddd".keys())?;
   |                        ^^^^^^^^^^^^^
   |                        |
   |                        expected struct `tui_react::terminal::Terminal`, found mutable reference
   |                        help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`
error[E0308]: mismatched types
  --> src/interactive/app_test/journeys_with_writes.rs:31:9
   |
31 |         &mut terminal,
   |         ^^^^^^^^^^^^^
   |         |
   |         expected struct `tui_react::terminal::Terminal`, found mutable reference
   |         help: consider removing the borrow: `terminal`
   |
   = note:         expected struct `tui_react::terminal::Terminal<_>`
           found mutable reference `&mut tui_react::terminal::Terminal<tui::backend::test::TestBackend>`

"File name too long" during git clone

Cloning into 'dua-cli'...                                                                                                                                                                      
remote: Enumerating objects: 510, done.                                                                                                                                                        
remote: Counting objects: 100% (510/510), done.                                                                                                                                                
remote: Compressing objects: 100% (230/230), done.                                                                                                                                             
remote: Total 1906 (delta 339), reused 440 (delta 279), pack-reused 1396                                                                                                                       
Receiving objects: 100% (1906/1906), 392.91 KiB | 8.73 MiB/s, done.                                                                                                                            
Resolving deltas: 100% (1250/1250), done.                                                                                                                                                      
error: unable to create file tests/fixtures/right-to-left/ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما
, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو.: File name too long                                                                                                                       
fatal: unable to checkout working tree                                                                                                                                                         
warning: Clone succeeded, but checkout failed.                                                                                                                                                 
You can inspect what was checked out with 'git status'                                                                                                                                         
and retry the checkout with 'git checkout -f HEAD'

This is on a Linux system with an EXT4 filesystem.

install.sh on Windows not working

  • Windows 10 1809
  • Having MSYS2 installed
  • Open cmd:
sh install.sh --git byron/dua-cli --crate dua
install.sh: GitHub repository: https://github.com/byron/dua-cli
install.sh: Crate: dua
install.sh: Tag: latest (v2.10.3)
install.sh: Target: x86_64-pc-windows-msvc
install.sh: Installing to: /c/Users/XXX/.cargo/bin
install.sh: Downloading: https://github.com/byron/dua-cli/releases/download/v2.10.3/dua-v2.10.3-x86_64-pc-windows-msvc.tar.gz
tar.exe: Error opening archive: Failed to open '\\.\tape0'
(23) Failed writing body

Opening with associated program may write over TUI

When using Ctrl + O to open the file, the associated program may write over the TUI. I've attached a screenshot of what happens with Nautilus. VLC does a similar thing.

garbage

I've used this workaround: Resize terminal, scroll, resize back and scroll again, but that's bothersome. It's probably best to suppress the output completely.

Request: skip & continue when directories/files do not have permission

When dua encounters a directory that it doesn't have permission to enter, the program prints an error essage and terminates:

$ ~/.cargo/bin/dua -f binary aggregate
Error: Permission denied (os error 13)
$ echo $?
1

It would be nice if it prints a more specific error message and continues, similar to du:

$ du -chs
du: cannot read directory './.config/gsmartcontrol': Permission denied
du: cannot read directory './.cache/dconf': Permission denied
du: cannot access './.cache/doc': Permission denied
du: cannot read directory './.dbus': Permission denied
du: cannot access './.gvfs': Permission denied
873G	.
873G	total
$ echo $?
1

My personal preference would be for this to be the default, but if it has to be enabled with an option so be it.

(du apparently doesn't have a way to turn off this behavior - which is fine by me).

edit:

I should have noted the dua version. When I went to correct this oversight I found that dua won't tell me:

mburr@mint-19:~$ ~/.cargo/bin/dua --version
dua 
mburr@mint-19:~$ ~/.cargo/bin/dua -V
dua 

support ctrl+z stop process

In interactive dua i, Ctrl+Z doesn't work. It does nothing. If I stop the process using kill -STOP <pid> on a separate terminal, it does stop. If I fg it on that terminal, it starts again, but the graphical interface is not there. Whatever I type seems to have no affect, and the text I type just shows. It even doesn't recognize Ctrl+C (in most cases). So I kill -KILL <pid>, and all the keys I inputted are spit out on that terminal.

Ideally, I would like Ctrl+Z to stop the process like many other programs.

Interactive Usage Bar Granularity

I think it would be nice to have the usage bar from interactive mode support the different eighths sections instead of just full or empty. I already have a hacky version that adds this functionality.

Incorrectly resolves symlinks

Symlinks that point to another disk are still counted for current one, resulting in total disk usage bigger than the disk capacity.

--version or -V doesn't tell the version

I installed dua yesterday and tried to get the version number for another (now closed) issue, but found that it wouldn't tell me:

mburr@mint-19:~$ ~/.cargo/bin/dua --version
dua 
mburr@mint-19:~$ ~/.cargo/bin/dua -V
dua 

I installed dua like so:

curl -LSfs https://raw.githubusercontent.com/byron/dua-cli/master/ci/install.sh |     sh -s -- --git byron/dua-cli --target x86_64-unknown-linux-musl --crate dua

Running on Linux Mint 19.3

dua --help suggests subcommand comes last

The help output suggests that subcommands come last:

$ ./.cargo/bin/dua -h
 Sat 11:48:24 
dua 2.10.3
A tool to learn about disk usage, fast!

USAGE:
    dua [FLAGS] [OPTIONS] [input]... [SUBCOMMAND]
: 

but actually that is not true, the subcommands come before the input dirs.
(Help for the subcommands correctly reflects that.)

File and directory count

I would be really cool to get information on file and directory counts. I'm not sure if anyone else wants this feature, but I'd certainly like to develop it.

Build fails on Windows due to termion errors

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\lib.rs:24:9
   |
24 | pub use sys::size::terminal_size;
   |         ^^^ maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\lib.rs:25:9
   |
25 | pub use sys::tty::{is_tty, get_tty};
   |         ^^^ maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
 --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\async.rs:5:5
  |
5 | use sys::tty::get_tty;
  |     ^^^ maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve: maybe a missing `extern crate sys;`?
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:29:5
   |
29 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:28:5
   |
28 | use sys::Termios;
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0425]: cannot find function `get_tty` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\async.rs:14:36
   |
14 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
   |                                    ^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_tty` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\async.rs:43:36
   |
43 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
   |                                    ^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:45:9
   |
45 |         set_terminal_attr(&self.prev_ios).unwrap();
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:90:23
   |
90 |         let mut ios = get_terminal_attr()?;
   |                       ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `raw_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:93:9
   |
93 |         raw_terminal_attr(&mut ios);
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
  --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:95:9
   |
95 |         set_terminal_attr(&ios)?;
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:106:9
    |
106 |         set_terminal_attr(&self.prev_ios)?;
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:111:23
    |
111 |         let mut ios = get_terminal_attr()?;
    |                       ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `raw_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:112:9
    |
112 |         raw_terminal_attr(&mut ios);
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
   --> C:\Users\Roy\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.2\src\raw.rs:113:9
    |
113 |         set_terminal_attr(&ios)?;
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error: aborting due to 15 previous errors

Some errors occurred: E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0425`.
error: Could not compile `termion`.
warning: build failed, waiting for other jobs to finish...

Hardlinked files are not counted properly

The same file can appear in multiple places in a directory hierarchy. This includes things like Rust's own build directories, /rescue partitions with tools like busybox, backups using rsync --link-dest, and so forth.

Traditional du's deal with this by keeping a map of seen inodes and their link counts, and avoid counting additional copies of the same inode - decrementing the link count until all have been seen and the inode can be forgotten. This may not be perfect for an interactive tool like this, but it would probably be better than nothing.

support showing timestamps for files/dirs

It is often useful to know how old a file or directory is when deciding if it can be deleted say.
It would be a nice feature to add to dua in my opinion: I don't think they need be cached.

fails to build due to process_read_dir argument error

error[E0593]: closure is expected to take 4 arguments, but it takes 2 arguments
   --> /home/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/dua-cli-2.10.7/src/common.rs:139:14
    |
139 |             .process_read_dir(|_, dir_entry_results| {
    |              ^^^^^^^^^^^^^^^^ ---------------------- takes 2 arguments
    |              |
    |              expected closure that takes 4 arguments

This appears to be due to a breaking change in jwalk between version 0.5.0 and 0.5.2.

`cargo test` fails with 2.6.1 on Fedora

2.6.0 was just fine.

     Running `/usr/bin/rustc --crate-name dua --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C opt-level=3 --test -C metadata=228cdbfea33370d8 -C extra-filename=-228cdbfea33370d8 --out-dir /builddir/build/BUILD/dua-cli-2.6.1/target/release/deps -L dependency=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps --extern atty=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libatty-efc19819d1e9ac80.rlib --extern byte_unit=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libbyte_unit-9917bd0f9c97097c.rlib --extern failure=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libfailure-e093753d2ec7c7c4.rlib --extern failure_tools=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libfailure_tools-30b5aa0b3d43fa94.rlib --extern filesize=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libfilesize-bc04f6e10858ccda.rlib --extern flume=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libflume-1e130c8f2ab3217a.rlib --extern itertools=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libitertools-8e2ba6bcd515d3d0.rlib --extern jwalk=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libjwalk-abacfb9894dbf2f7.rlib --extern log=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/liblog-4f78b14c47d616f3.rlib --extern num_cpus=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libnum_cpus-a99fc62929d3f35a.rlib --extern open=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libopen-5b63bcbf351a5fce.rlib --extern petgraph=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libpetgraph-7caee99cf66647d3.rlib --extern pretty_assertions=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libpretty_assertions-053e62e3fbe5376b.rlib --extern structopt=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libstructopt-2be276fcf633a1ba.rlib --extern termion=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libtermion-84f1efa561a3024a.rlib --extern tui=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libtui-cea60341ec7a6847.rlib --extern tui_react=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libtui_react-9232341d273ced1f.rlib --extern unicode_segmentation=/builddir/build/BUILD/dua-cli-2.6.1/target/release/deps/libunicode_segmentation-6a1ece1fa7c08bb8.rlib -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now -Ccodegen-units=1 --cap-lints=warn`
error[E0583]: file not found for module `app_test`
  --> src/interactive/mod.rs:35:5
   |
35 | mod app_test;
   |     ^^^^^^^^
   |

Could use -x flag

Would be really nice if dua would support -x for "don't cross filesystem boundaries"…

Are there any plans for adding binary release?

@Byron This tool is awesome. Thanks for your brillient work!

Currently we have to install the entire set of rust SDK to compile and install it. This is a bit cumbersome for non-rust users. This also prevents us from using it on some server environment.

So would you consider adding support for binary releases?

Tauri-GUI as alternative to TUI

Tauri is a framework that seems to get so much right that this would be my opportunity to give it a trial run with a simple user interface.

https://tauri.studio

In short, use the OS browser to deliver a GUI using web-technology, but with all the benefits of running as desktop application.

Related to #2

No license files in tui-react crate

Terribly sorry, but i found only now this -- we need to add license files in tui-react crate as well.

And no license file at dua-cli crate (ver 2.3.1).

ctrl+r doesn't work?

First of all! It is really nifty!

However in interactive mode I can't figure out a way to delete anything. In help I've found ctrl+r, but it doesn't seem to do anything. And I would actually prefer pressing d or Del and getting a prompt, anyway.

[Suggestion] Show progress while analyzing

Suggestion:

Make dua display a progress bar or some kind of activity indicator while it's analyzing the disk, so that the user realizes that the program is doing some work and didn't hang.

When I first ran it (on Windows) I thought that it's stuck, but it turned out that dua was actually working, it just took a while to complete (a few minutes for my system disk).

parallel deletion (without following symlinks) using jwalk

Previously jwalk would follow symlinks, so we could not use it and instead implemented our own traversal.

Now with jwalk 0.5, this is supported and we can use our standard jwalker to do the job.

let mut files_or_dirs = vec![path];
let mut dirs = Vec::new();
let mut num_errors = 0;
while let Some(path) = files_or_dirs.pop() {
let assume_symlink_to_try_deletion = true;
let is_symlink = path
.symlink_metadata()
.map(|m| m.file_type().is_symlink())
.unwrap_or(assume_symlink_to_try_deletion);
if is_symlink {
// do not follow symlinks
num_errors += into_error_count(fs::remove_file(&path));
continue;
}
match fs::read_dir(&path) {
Ok(iterator) => {
dirs.push(path);
for entry in iterator {
match entry.map_err(io_err_to_usize) {
Ok(entry) => files_or_dirs.push(entry.path()),
Err(c) => num_errors += c,
}
}
}
Err(ref e) if e.kind() == io::ErrorKind::Other => {
// assume file, save IOps
num_errors += into_error_count(fs::remove_file(path));
continue;
}
Err(_) => {
num_errors += 1;
continue;
}
};
}

The function above would have to change to use jwalk. It should be straightforward to obtain a walker with this function:

dua-cli/src/common.rs

Lines 162 to 184 in 0d6116e

impl WalkOptions {
pub(crate) fn iter_from_path(&self, path: &Path) -> WalkDir {
WalkDir::new(path)
.follow_links(false)
.sort(match self.sorting {
TraversalSorting::None => false,
TraversalSorting::AlphabeticalByFileName => true,
})
.skip_hidden(false)
.process_read_dir(|_, dir_entry_results| {
dir_entry_results.iter_mut().for_each(|dir_entry_result| {
if let Ok(dir_entry) = dir_entry_result {
dir_entry.client_state = Some(dir_entry.metadata());
}
})
})
.parallelism(if self.threads == 0 {
jwalk::Parallelism::RayonDefaultPool
} else {
jwalk::Parallelism::RayonNewPool(self.threads)
})
}
}

Unsure about 'quit without delay from interactive mode'

I'm afraid I don't understand what the following changelog entry for the newest 2.6.1 version means:

quit without delay from interactive mode after having looked at big directory trees

I tried to locate the related commit but didn't succeed.
Would you mind adding a few explanations ?

Thanks !

How to exclude certain directories?

Hello,

At work, the IS team creates a ~/.snapshot directory in each user's home. That .snapshot directory is a symlink to a remote disk and does not consume my disk space, but it's huge as it has hourly, daily, monthly, etc backups created automatically.

It would be nice to have a --exclude flag like ncdu.

Thanks for this project.

Failure in readme install instructions

~> curl -LSfs https://raw.githubusercontent.com/byron/dua-cli/master/ci/install.sh | \                                                                   1s 757ms
                               sh -s -- --git byron/dua-cli --crate dua
install.sh: GitHub repository: https://github.com/byron/dua-cli
install.sh: Crate: dua
install.sh: Tag: latest (v2.10.2)
install.sh: Target: x86_64-unknown-linux-gnu
install.sh: Installing to: /home/james/.cargo/bin
install.sh: Downloading: https://github.com/byron/dua-cli/releases/download/v2.10.2/dua-v2.10.2-x86_64-unknown-linux-gnu.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Cargo.lock issue

Hi @Byron!
Thanks for including the Cargo.lock file in the release! Although there's a small issue about it: the crate's version in Cargo.lock doesn't match one in the Cargo.toml (2.1.3 and 2.1.4 respectively), which effectively prevents building the crate with the --locked flag :(
Could you please maybe check somehow that cargo build doesn't modify the git root? This will help to ensure that the up-to-date version of Cargo.lock is released :)

Thanks!

Some tests not passed

Hello. Some tests not passed on Fedora. Maybe it is safe to disable them? Would appreciate any tip.

failures:
    interactive::app_test::journeys_readonly::simple_user_journey_read_only
    interactive::app_test::journeys_with_writes::basic_user_journey_with_deletion
    interactive::app_test::unit::it_can_handle_ending_traversal_reaching_top_but_skipping_levels
    interactive::app_test::unit::it_can_handle_ending_traversal_without_reaching_the_top

test result: FAILED. 1 passed; 4 failed; 0 ignored; 0 measured; 0 filtered out

Redraw on terminal resize

Awesome application! Would be nice to have redraw on terminal resize, not sure how difficult that would be with termion.

feature-toggle for TUI

The first step toward windows support could be to build it without the terminal user interface which will never support windows.

For that, one should add a feature toggle that is off on windows builds. If that's not possible, use conditional compilation.

Related to #2

Output in interactive mode gets visually corrupted when size of first 2 columns changes.

Output in interactive mode gets corrupted when scanning a big directory (200 TiB of data).

Like the first entry should be cbravo.
A lot of entries are corrupted by a dir called bvds (probably because the with of the first 2 columns changed so it didn't overwrite characters that where there.

/some/dir/with/lots/of/files_and_dirs (3 10 items)──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
└─  7─41─T───────██ ──dwm x ravo                                                                                                                                                                                                          ┘
    2 34 T              bvcbravo
    1 31 T   █          dsvpotier
    1.03 TB |█         |bvdsvet re
  711.71 GB |█         |cfbvds
  309.28 GB |          |  cflerin
  119.21 GB |          |  dkoldere
    1.98 GB |          |  dmauduit
    8.20 KB |          |  .DS_Store
    4.10 KB |          |  ._.DS_Store

Total disk usage: -  Entries: 10247281   -> scanning <-──

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.