Code Monkey home page Code Monkey logo

dutree's People

Contributors

ahoetker avatar asomers avatar ignatenkobrain avatar itsnickbarry avatar lambda avatar nachoparker avatar parrotmac avatar tom-heimbrodt avatar wezm 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

dutree's Issues

Building from source: errors

I am using version 0.2.15
Installed latest version of rust for ubuntu (sudo apt-get update && sudo apt-get install rustc)

kurdtpage@ubuntu:~/dutree-0.2.15/src$ rustc main.rs
error[E0463]: can't find crate for `dutree`
  --> main.rs:37:1
   |
37 | extern crate dutree;
   | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

[FEATURE] Allow to diff over time

It would be useful if it was possible to save a log with current disk usage to later come back and run a diff against the log instead of another directory. My usecase is i have a server that's slowly filling up und i have no idea where the space is going.

Nice tool by the way.

Issues with Unicode characters and --no-hidden option πŸ‹

I have a file named πŸ‹.mp3.

Running dutree -H yields this error:

thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'πŸ‹' (bytes 0..4) of `πŸ‹.mp3`', libcore/str/mod.rs:2238:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

The error occurs with other Unicode characters as well, but only when the -H option is passed.

Here's the rest of the error when I set RUST_BACKTRACE=1:

stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::str::slice_error_fail
  10: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeTo<usize>>::index::{{closure}}
  11: dutree::Entry::new
  12: dutree::run
  13: dutree::main
  14: std::rt::lang_start::{{closure}}
  15: std::panicking::try::do_call
  16: __rust_maybe_catch_panic
  17: std::rt::lang_start_internal
  18: main
  19: __libc_start_main
  20: _start

`Where have the space gone?` feature

1 a user triggers a FS scan
2 the app scans the fs and records exacts sizes of each file into an SQLite db alongside with its hash and some metadata. Let's call it "a snapshot".

Time passes, some app eats space.

3 the user creates an another snapshot
4 snapshots are stored in a differential way saving space.
5 A user selects a pair of snapshots, the app computes their diff and shows to a user sorting by size difference.
6 there should be a way to create a snapshot and compare it to the previous one without involving any storage. This is needed because
a) the storage may have 0 (ZERO) bytes of free space and to free it it is crucial to understand what have eaten it
b) and doesn't inflict flash wear

Core Dump when using "dutree | less"

When using "dutree | less" on Linux on a directory with more than a screen size of directories and then pressing "q" to quit the paging, gives a rust dump:
thread 'main' panicked at 'already borrowed: BorrowMutError', library/std/src/io

/stdio.rs:564:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'Once instance has previously been poisoned', library/std/src/sync/once.rs:392:21
fatal runtime error: failed to initiate panic, error 5

Stack trace:

thread 'main' panicked at 'already borrowed: BorrowMutError', library/std/src/io/stdio.rs:564:23
stack backtrace:
   0:     0x55b343b59c70 - std::backtrace_rs::backtrace::libunwind::trace::h5e9d00f0cdf4f57e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x55b343b59c70 - std::backtrace_rs::backtrace::trace_unsynchronized::hd5302bd66215dab9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55b343b59c70 - std::sys_common::backtrace::_print_fmt::ha0237cd11a34e2bf
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x55b343b59c70 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h171d4c10df1a98ee
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x55b343b7674c - core::fmt::write::h89e4288724daa3fa
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/fmt/mod.rs:1096:17
   5:     0x55b343b57162 - std::io::Write::write_fmt::h6d40f996e84584d9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/mod.rs:1568:15
   6:     0x55b343b5bb75 - std::sys_common::backtrace::_print::h0c0b93221682afc8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x55b343b5bb75 - std::sys_common::backtrace::print::h57a9f95204c2fdd6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x55b343b5bb75 - std::panicking::default_hook::{{closure}}::h4245258b50e37e69
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:208:50
   9:     0x55b343b5b6d3 - std::panicking::default_hook::h7b00dcc1d0944747
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:225:9
  10:     0x55b343b5c311 - std::panicking::rust_panic_with_hook::h71e6a073d87de1f5
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:591:17
  11:     0x55b343b5be57 - std::panicking::begin_panic_handler::{{closure}}::hd549436f6bb6dbb8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:497:13
  12:     0x55b343b5a10c - std::sys_common::backtrace::__rust_end_short_backtrace::h4e5f4b72b04174c3
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x55b343b5bdb9 - rust_begin_unwind
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
  14:     0x55b343b75151 - core::panicking::panic_fmt::hcd56f7f635f62c74
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
  15:     0x55b343b74f73 - core::option::expect_none_failed::hf37eebedadde29e6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/option.rs:1300:5
  16:     0x55b343b41082 - core::result::Result<T,E>::expect::haea4de697cc1b2a6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/result.rs:997:23
  17:     0x55b343b41082 - core::cell::RefCell<T>::borrow_mut::h41246c870ea45ae7
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/cell.rs:872:9
  18:     0x55b343b41082 - std::io::stdio::stdout::cleanup::h5fe2149c581ad9ed
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/stdio.rs:564:18
  19:     0x55b343b41082 - core::ops::function::FnOnce::call_once::h97188099de37fa9a
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:227:5
  20:     0x55b343b41082 - core::ops::function::FnOnce::call_once{{vtable.shim}}::ha0500ef8640e8c08
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:227:5
  21:     0x55b343b591ef - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h61144a2be4ee36d8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1521:9
  22:     0x55b343b591ef - std::sys_common::at_exit_imp::cleanup::h593b116fd49dd0a9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/at_exit_imp.rs:55:21
  23:     0x55b343b591ef - std::sys_common::cleanup::{{closure}}::h0d9d62949cd90a56
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/mod.rs:131:9
  24:     0x55b343b591ef - std::sync::once::Once::call_once::{{closure}}::h0cfcece65d026d5b
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sync/once.rs:261:41
  25:     0x55b343b598f2 - std::sync::once::Once::call_inner::he4820d88e5388bd4
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sync/once.rs:418:21
  26:     0x55b343b5b150 - std::sync::once::Once::call_once::hbe12a4610ab92c7e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sync/once.rs:261:9
  27:     0x55b343b5b150 - std::sys_common::cleanup::h912bf26f5936ecd8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/mod.rs:128:5
  28:     0x55b343b59008 - std::process::exit::h82c2004e414b4974
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/process.rs:1722:5
  29:     0x55b343aaf379 - dutree::main::{{closure}}::h9d0e399ec041d6a3
  30:     0x55b343aaf1b6 - signal_hook_registry::register::{{closure}}::haa33727df13187a3
  31:     0x55b343ab0497 - signal_hook_registry::handler::h8f515f388ec2ea1a
  32:     0x7f70560202d0 - <unknown>
  33:     0x7f705601edb4 - __write
  34:     0x55b343b54a0f - std::sys::unix::fd::FileDesc::write::h7684fcb3a9eb0e1c
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys/unix/fd.rs:146:13
  35:     0x55b343b54a0f - <std::sys::unix::stdio::Stdout as std::io::Write>::write::hf8566822631c3802
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys/unix/stdio.rs:38:9
  36:     0x55b343b54a0f - <std::io::stdio::StdoutRaw as std::io::Write>::write::he0094c1abece03d5
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/stdio.rs:128:22
  37:     0x55b343b54a0f - std::io::buffered::bufwriter::BufWriter<W>::flush_buf::h7a9ea302f83154f0
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/buffered/bufwriter.rs:162:21
  38:     0x55b343b55bbe - <std::io::buffered::linewritershim::LineWriterShim<W> as std::io::Write>::write_all::hed70a16be165666b
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/buffered/linewritershim.rs:269:21
  39:     0x55b343b55bbe - <std::io::buffered::linewriter::LineWriter<W> as std::io::Write>::write_all::h24df81442e65111d
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/buffered/linewriter.rs:206:9
  40:     0x55b343b55bbe - <std::io::stdio::StdoutLock as std::io::Write>::write_all::h1823251172a52664
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/stdio.rs:682:9
  41:     0x55b343b57547 - <std::io::Write::write_fmt::Adaptor<T> as core::fmt::Write>::write_str::he2bea8ca4e6d810c
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/mod.rs:1557:23
  42:     0x55b343b767b2 - core::fmt::write::h89e4288724daa3fa
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/fmt/mod.rs:1115:9
  43:     0x55b343b5598b - std::io::Write::write_fmt::heebd259fdaae56c7
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/mod.rs:1568:15
  44:     0x55b343b5598b - <&std::io::stdio::Stdout as std::io::Write>::write_fmt::h46cdbb05ad893dab
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/stdio.rs:662:9
  45:     0x55b343b55ff8 - <std::io::stdio::Stdout as std::io::Write>::write_fmt::ha489d02e32ee4859
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/stdio.rs:636:9
  46:     0x55b343b55ff8 - std::io::stdio::print_to::he3eeefb914061c9b
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/stdio.rs:939:21
  47:     0x55b343b55ff8 - std::io::stdio::_print::hfdac4ecf8a146755
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/stdio.rs:952:5
  48:     0x55b343ab6c5e - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  49:     0x55b343ab6d14 - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  50:     0x55b343ab6d14 - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  51:     0x55b343ab6d14 - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  52:     0x55b343ab6d14 - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  53:     0x55b343ab6d14 - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  54:     0x55b343ab6d14 - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  55:     0x55b343ab6d14 - dutree::Entry::print_entries::h8277e18bd4eb5d3d
  56:     0x55b343ab921e - dutree::run::h969af363ab0e0312
  57:     0x55b343aaf76a - dutree::main::h3a0d03cdd0f3c9c9
  58:     0x55b343aaf413 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb98a86915936f1fa
  59:     0x55b343aad389 - std::rt::lang_start::{{closure}}::h81109c7e71b23bab
  60:     0x55b343b5c737 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h527fb2333ede305e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:259:13
  61:     0x55b343b5c737 - std::panicking::try::do_call::h309d8aee8149866c
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:379:40
  62:     0x55b343b5c737 - std::panicking::try::h75a60c31fd16bfc6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:343:19
  63:     0x55b343b5c737 - std::panic::catch_unwind::h1f9892423e99bc00
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panic.rs:431:14
  64:     0x55b343b5c737 - std::rt::lang_start_internal::hd5b67df56ca01dae
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/rt.rs:51:25
  65:     0x55b343aaf8c2 - main
  66:     0x7f7055a7234a - __libc_start_main
  67:     0x55b343aab42a - <unknown>
                               at /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120
  68:                0x0 - <unknown>
thread 'main' panicked at 'Once instance has previously been poisoned', library/std/src/sync/once.rs:392:21
stack backtrace:
   0:     0x55b343b59c70 - std::backtrace_rs::backtrace::libunwind::trace::h5e9d00f0cdf4f57e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x55b343b59c70 - std::backtrace_rs::backtrace::trace_unsynchronized::hd5302bd66215dab9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55b343b59c70 - std::sys_common::backtrace::_print_fmt::ha0237cd11a34e2bf
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x55b343b59c70 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h171d4c10df1a98ee
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x55b343b7674c - core::fmt::write::h89e4288724daa3fa
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/fmt/mod.rs:1096:17
   5:     0x55b343b57162 - std::io::Write::write_fmt::h6d40f996e84584d9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/mod.rs:1568:15
   6:     0x55b343b5bb75 - std::sys_common::backtrace::_print::h0c0b93221682afc8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x55b343b5bb75 - std::sys_common::backtrace::print::h57a9f95204c2fdd6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x55b343b5bb75 - std::panicking::default_hook::{{closure}}::h4245258b50e37e69
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:208:50
   9:     0x55b343b5b6d3 - std::panicking::default_hook::h7b00dcc1d0944747
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:225:9
  10:     0x55b343b5c311 - std::panicking::rust_panic_with_hook::h71e6a073d87de1f5
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:591:17
  11:     0x55b343b5c124 - std::panicking::begin_panic::{{closure}}::h226205cfbc146caa
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:520:9
  12:     0x55b343b5a12c - std::sys_common::backtrace::__rust_end_short_backtrace::h9599e90d24cd3cd7
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x55b343b5c0fc - std::panicking::begin_panic::heb23b64fde311f4f
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:519:12
  14:     0x55b343b5997e - std::sync::once::Once::call_inner::he4820d88e5388bd4
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sync/once.rs:392:21
  15:     0x55b343b5c780 - std::sync::once::Once::call_once::hbe12a4610ab92c7e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sync/once.rs:261:9
  16:     0x55b343b5c780 - std::sys_common::cleanup::h912bf26f5936ecd8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/mod.rs:128:5
  17:     0x55b343b5c780 - std::rt::lang_start_internal::hd5b67df56ca01dae
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/rt.rs:53:9
  18:     0x55b343aaf8c2 - main
  19:     0x7f7055a7234a - __libc_start_main
  20:     0x55b343aab42a - <unknown>
                               at /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120
  21:                0x0 - <unknown>
fatal runtime error: failed to initiate panic, error 5

dutree shows that `/proc` consumes more bytes than grains of sand on Earth

It seems that wasn't the expected behavior.
Let me post a screenshot cause pasted text has \u[d+] symbols.
image

~ uname -a                         
Linux dell 5.9.12-arch1-1 #1 SMP PREEMPT Wed, 02 Dec 2020 16:14:56 +0000 x86_64 GNU/Linux

Let me know if that's reproducible on other machines and if you need additional information.

--usage should be the default

Tools like dutree or du are generally used for finding files to clean up to free up space. The space that will be freed up corresponds to the files block usage on disk, not the file size, which could be smaller due to not using entire blocks, or larger due to a file having holes.

While there may be some circumstances where the file size is useful to know, for instance if transferring to some other system which doesn't support holes in files and does't round to block boundaries, for the most common use cases --usage is the better metric, and it's even implicit in the name, where du stands for "disk usage."

panic when piped to `head`

$ dutree --version
dutree version v0.2.9
$ dutree -s | head -n 1
Unable to get terminal size
[ git 19.28 GiB ]
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', src/libstd/io/stdio.rs:792:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

dutree is slow compared to du

I compared dutree to my usual go-to solution of du -h -d3 | sort -h on my src directory, and it is much slower.

This is on macOS, and this is after having run these a few times to warm up caches.

I suspect the reason for this is that you're doing too many syscalls; the code seems to use Path to refer to files in many places, and then does various tests on those paths, which mean extra system calls to query the same information multiple times. I would recommend instead passing around DirEntry, from which many attributes can be queried without extra system calls, or even better using the walkdir crate which is a pretty well optimized directory walker that provides its own slightly richer DirEntry that caches additional metadata.

$ time sh -c 'du -h -d3 | gsort -h'
...
real	0m36.430s
user	0m1.801s
sys	0m14.163s
$ time dutree --aggr=100m -d3
...
163.37 real        11.67 user       104.74 sys

OS X installation problem

$ cargo install dutree
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading dutree v0.2.5
  Installing dutree v0.2.5
 Downloading getopts v0.2.17
 Downloading regex v0.2.11
 Downloading terminal_size v0.1.7
 Downloading unicode-segmentation v1.2.1
 Downloading unicode-width v0.1.4
 Downloading thread_local v0.3.5
 Downloading memchr v2.0.1
 Downloading utf8-ranges v1.0.0
 Downloading aho-corasick v0.6.4
 Downloading regex-syntax v0.5.6
 Downloading unreachable v1.0.0
 Downloading lazy_static v1.0.0
 Downloading void v1.0.2
 Downloading libc v0.2.40
 Downloading ucd-util v0.1.1
 Downloading winapi v0.2.8
 Downloading kernel32-sys v0.2.2
 Downloading winapi-build v0.1.1
   Compiling winapi v0.2.8
   Compiling getopts v0.2.17
   Compiling utf8-ranges v1.0.0
   Compiling regex v0.2.11
   Compiling unicode-width v0.1.4
   Compiling winapi-build v0.1.1
   Compiling libc v0.2.40
   Compiling void v1.0.2
   Compiling ucd-util v0.1.1
   Compiling unicode-segmentation v1.2.1
   Compiling lazy_static v1.0.0
   Compiling unreachable v1.0.0
   Compiling kernel32-sys v0.2.2
   Compiling memchr v2.0.1
   Compiling regex-syntax v0.5.6
   Compiling thread_local v0.3.5
   Compiling aho-corasick v0.6.4
   Compiling terminal_size v0.1.7
   Compiling dutree v0.2.5
error[E0433]: failed to resolve. Could not find `linux` in `os`
  --> src/lib.rs:55:14
   |
55 | use std::os::linux::fs::MetadataExt;
   |              ^^^^^ Could not find `linux` in `os`

error[E0599]: no method named `st_blocks` found for type `std::fs::Metadata` in the current scope
   --> src/lib.rs:230:50
    |
230 |         Ok(metadata) => if usage_flag { metadata.st_blocks()*512 } else { metadata.st_size() },
    |                                                  ^^^^^^^^^
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
    |
38  | use std::os::macos::fs::MetadataExt;
    |

error[E0599]: no method named `st_size` found for type `std::fs::Metadata` in the current scope
   --> src/lib.rs:230:84
    |
230 |         Ok(metadata) => if usage_flag { metadata.st_blocks()*512 } else { metadata.st_size() },
    |                                                                                    ^^^^^^^
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
    |
38  | use std::os::macos::fs::MetadataExt;
    |

error[E0599]: no method named `st_mode` found for type `std::fs::Metadata` in the current scope
   --> src/lib.rs:483:38
    |
483 |         let mode = metadata.unwrap().st_mode();
    |                                      ^^^^^^^
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
    |
38  | use std::os::macos::fs::MetadataExt;
    |

error: aborting due to 4 previous errors

error: failed to compile `dutree v0.2.5`, intermediate artifacts can be found at `/var/folders/28/yf_8fv7s6694pyt259fdlc5m0000gn/T/cargo-install.osYK5NbwvVEz`

Caused by:
  Could not compile `dutree`.

To learn more, run the command again with --verbose.

On mac OS High Sierra

$ uname -a
Darwin mini500.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64
$ rustc --version
rustc 1.25.0
$ cargo --version
cargo 0.25.0

Is it support Chinese filename?

i get this when ithe floader has file which name has Chinese:

thread 'main' panicked at 'assertion failed: self.is_char_boundary(new_len)', liballoc/string.rs:1020:13 note: Run with RUST_BACKTRACE=1 for a backtrace.

the filename is ζˆ‘ε₯½εƒζ…δΊ†ι©¬θœ‚ηͺοΌšζ˜―δΌͺε₯³ζƒοΌŒθΏ˜ζ˜―ε–ζ·«δΊ§δΈšι“ΎοΌŸ.pdf

Overwhelmed with large sizes

I have a 6TB HDD with a single file on it that is about 5.4TB large. When I inspect any part of the hard drive with dutree then it doesn't show the size of the folder/files, but replaces any number of size with inf.
Example:

root@hostname:/mnt/t/b# dutree -s
[ b inf TiB ]
└─ plots                    β”‚ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚ 100%       inf TiB

root@hostname:/mnt/t/b/plots# dutree -s
[ plots inf TiB ]
└─ file_name                β”‚ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚ 100%       inf TiB

crate error

run cargo build
get the error:

extern crate unicode_segmentation;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
lack of something?

Unable to build with --locked due to missing Cargo.lock

603b9fe removed the Cargo.lock file. This means it's not possible to build with the --locked argument with cargo. This is preferred when building packages from tagged releases to ensure that exactly the same version of dependencies are used, which helps ensure builds are reproducible. For binary projects it is recommended to commit the lock file: https://doc.rust-lang.org/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries

Would it be possible to include the lock file in future releases?

error: linker `cc` not found

On

  • ubuntu 22.04
  • cargo 1.76.0
  • hash: 44e877d

running

cargo build 

yields

   Compiling libc v0.2.71
   Compiling memchr v2.3.3
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `memchr` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `libc` (build script) due to 1 previous error

Panic!

after installing with cargo ...

thread 'main' panicked at 'called Option::unwrap() on a None value', /home/nadim/.cargo/registry/src/github.com-1ecc6299db9ec823/dutree-0.2.18/src/lib.rs:565:36
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

dutree doesn't account for hard links

Something that the standard du gets correct but dutree does not is avoid double-counting the usage of multiple directory entires that refer to the same files (hard links). Since you are generally using du to account for total disk usage, you wouldn't want to double-count files that are stored once but have multiple directory entries.

For example:

$ tree --inodes
.
β”œβ”€β”€ [116445601]  bar
β”œβ”€β”€ [116445607]  d
β”‚Β Β  β”œβ”€β”€ [116445608]  a
β”‚Β Β  └── [116445601]  b
└── [116445601]  foo

1 directory, 4 files

$ du -ha .
4.0K	./bar
4.0K	./d/a
4.0K	./d
8.0K	.

$ dutree
[ dutest 327 B ]
β”œβ”€ d             β”‚                        β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚  44%         145 B
β”‚  β”œβ”€ b          β”‚                        β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β”‚   4%           6 B
β”‚  └─ a          β”‚                        β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β”‚   2%           3 B
β”œβ”€ bar           β”‚                                         β”‚   1%           6 B
└─ foo           β”‚                                         β”‚   1%           6 B

$ dutree --usage
[ dutest 16.00 KiB ]
β”œβ”€ d             β”‚                      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚  50%      8.00 KiB
β”‚  β”œβ”€ a          β”‚                      β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚  50%      4.00 KiB
β”‚  └─ b          β”‚                      β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚  50%      4.00 KiB
β”œβ”€ bar           β”‚                                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚  25%      4.00 KiB
└─ foo           β”‚                                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ”‚  25%      4.00 KiB

As we can see, dutree --usage overestimates the space used significantly compared to du

How these should be displayed is a bit of an open question. du prints files from the bottom up, and skips displaying files for which it has already covered the give inode. However, for dutree it might make sense to still show the individual files in the tree structure, but skip adding them to the common parent size. I'm not sure which approach would be better.

thread 'main' panicked at 'attempt to divide by zero':

dutree crashes when it sees a directory with is 0 bytes in size (directory in a CIFS mounted path).

thread 'main' panicked at 'attempt to divide by zero', /software/rust/cargo/registry/src/github.com-1ecc6299db9ec823/dutree-0.2.9/src/lib.rs:447:32
$ RUST_BACKTRACE=1 dutree .TemporaryItems/
[ .TemporaryItems 0 B ]
thread 'main' panicked at 'attempt to divide by zero', libcore/ops/arith.rs:453:45
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:476
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   6: rust_begin_unwind
             at libstd/panicking.rs:325
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   8: core::panicking::panic
             at libcore/panicking.rs:52
   9: dutree::Entry::print_entries
  10: dutree::run
  11: dutree::main
  12: std::rt::lang_start::{{closure}}
  13: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  14: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  15: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  16: main
  17: __libc_start_main
  18: <unknown>

$ find .TemporaryItems/ -ls
333090    0 drwxr-xr-x   2 user group        0 Jan  3  2017 .TemporaryItems/
392765    0 drwxr-xr-x   2 user group        0 Apr 24  2014 .TemporaryItems/folders.1348605550
392775    0 drwxr-xr-x   2 user group        0 Apr 24  2014 .TemporaryItems/folders.1348605550/TemporaryItems
392766    0 drwxr-xr-x   2 user group        0 Apr 24  2014 .TemporaryItems/folders.41167355
392767    0 drwxr-xr-x   2 user group        0 Oct  1  2014 .TemporaryItems/folders.239773687
392768    0 drwxr-xr-x   2 user group        0 Nov  5  2015 .TemporaryItems/folders.1184298059
392769    0 drwxr-xr-x   2 user group        0 Dec  1  2014 .TemporaryItems/folders.865972762
392776    0 drwxr-xr-x   2 user group        0 Dec  1  2014 .TemporaryItems/folders.865972762/TemporaryItems
392770    0 drwxr-xr-x   2 user group        0 Feb  4  2015 .TemporaryItems/folders.1738237123
392771    0 drwxr-xr-x   2 user group        0 Aug 28  2017 .TemporaryItems/folders.1855339908
392777    0 drwxr-xr-x   2 user group        0 Aug 28  2017 .TemporaryItems/folders.1855339908/Cleanup\ At\ Startup
392772    0 drwxr-xr-x   2 user group        0 Aug  9  2016 .TemporaryItems/folders.501
392773    0 drwxr-xr-x   2 user group        0 Oct 18  2016 .TemporaryItems/folders.1326020712
392778    0 drwxr-xr-x   2 user group        0 Dec  7  2017 .TemporaryItems/folders.1326020712/Cleanup\ At\ Startup
392774    0 drwxr-xr-x   2 user group        0 Jan 31  2018 .TemporaryItems/folders.1562120262

filter by date

I love to use dutree. I don't know anything about rust.

Feature request: ignore files older or younger than a certain date.

Is that possible?

[FEATURE] Filtering by extension/pattern?

I see there is the -x option, but no example.

-x, --exclude NAME exclude matching files or directories

It only accepts full filename? Would it be possible to support matching a filter pattern? -p --pattern PATTERN Where you can use a pattern for filtering the results via globs, include/exclude extensions *.webp,*.jpg(only match these), or exclude *.gif,preview*.

In my case, I just wanted to identify results with a certain file extension, doesn't seem possible currently?

Thanks for the great tool, it's been helpful, using some native system commands on a server wasn't working in large directories, either raising an error that the arg list was too long, or being unresponsive for a long time with no feedback. dutree handled these directories like a champ! :)

Option to not follow symlinks / stay on one filesystem

-x should have been "stay on one filesystem" instead of "exclude", for parity with du and ncdu.

Anyway, there should be something like -X then to avoid going to other filesystems mounted below this one and options to avoid following symlinks (or maybe it should not follow symlinks by default unless -L).

doesn't install on windows

Compiling terminal_size v0.1.8
Compiling dutree v0.2.9
error[E0425]: cannot find value mode in this scope
--> C:\Users\Dominic E Sisneros.cargo\registry\src\github.com-1ecc6299db9ec823\dutree-0.2.9\src\lib.rs:494:16
|
494 | if mode & 0o002 != 0 { // dir other writable
| ^^^^ not found in this scope

error[E0425]: cannot find value mode in this scope
--> C:\Users\Dominic E Sisneros.cargo\registry\src\github.com-1ecc6299db9ec823\dutree-0.2.9\src\lib.rs:503:12
|
503 | if mode & 0o111 != 0 { // executable
| ^^^^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try rustc --explain E0425.
error: failed to compile dutree v0.2.9, intermediate artifacts can be found at C:\Users\DOMINI~2\AppData\Local\Temp\1\cargo-installHdRu0K

Caused by:
Could not compile dutree.

To learn more, run the command again with --verbose.

C:\Users\Dominic E Sisneros>

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.