Implemented a progress indicator (#275)

* v1.0

* renamed operations to be more clear

* put info later because there is still operations par of the preparing process

* updated the last line clearing

* changed name of module and structs to ones that make more sens

* Disable size computation when file_count option is set

* added sleep during the thread waiting

* use 1024 powered instead of 10 to compute showed number

* include DS_Store

* added files directories skipped information

* small format update

* implement the -H option

* put wait back

* remove PAtomicInfo since it's not used

* cargo fmt

* wrapped atomic operations to reduce overhead

* updated comments

* Use AtomicU64Wrapper instead of AtomicU64 in TotalSize

* update size suffix

* sto dividing size when larger than terabytes

* Fix use_iso flag not be set properly

* update properties display

* some reformating

* use stdout instead of print

* Moved config instance into main because it's easier to read

* merge base formatting into macro

* update name to be more intuitive and separated math operations for more flexibility

* print currently indexed path

* cargo fmt

* reset size between each target dirs

* Access to TotalSize rather than it's inner

* small comment change

* Update sysinfo version to 0.26.7

* fix: update use of sysinfo.system

System is now much quicker to start but requires an explicit call
to refresh memory else it deafults to 0 (oops)

* clippy: Fix new clippy

* fix: bug where hard links could be double counted

When running:
dust dir_a dir_b

if a file was hard linked in both dir_a and dir_b it would be double
counted.

This fix resolves this by keeping the shared hashmap around between runs
for the second and subsequent arguments.
https://github.com/bootandy/dust/issues/282

* Fix: depth=0 bug for multiple arguments

https://github.com/bootandy/dust/issues/282

* refactor filter.rs

* refactor filter.rs

* refactor create AggregateData for filter.rs

* feature: Support for dereference links -L follow

du has -L flag which allows it to dereference or follow
symlinks. Clone this feature into dust.
https://github.com/bootandy/dust/issues/276

* refactor dir_walker

I find this layout cleaner

* v1.0

* changed name of module and structs to ones that make more sens

* Disable size computation when file_count option is set

* added files directories skipped information

* implement the -H option

* wrapped atomic operations to reduce overhead

* used human_readable_number function in display module rather than our own

* implemented progress disabling

* cargo fmt & cargo clippy

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
Co-authored-by: andy.boot <bootandy@gmail.com>
This commit is contained in:
NovaliX
2023-01-14 11:43:22 +00:00
committed by GitHub
parent ea3cc537ea
commit f3c074759d
13 changed files with 442 additions and 14 deletions
+38 -2
View File
@@ -7,11 +7,14 @@ mod filter;
mod filter_type;
mod node;
mod platform;
mod progress;
mod utils;
use crate::cli::build_cli;
use dir_walker::WalkData;
use filter::AggregateData;
use progress::PConfig;
use progress::PIndicator;
use std::collections::HashSet;
use std::io::BufRead;
use std::process;
@@ -165,6 +168,31 @@ fn main() {
.flat_map(|x| simplified_dirs.iter().map(move |d| d.join(&x)))
.collect();
let iso = config.get_iso(&options);
let ignore_hidden = config.get_ignore_hidden(&options);
let disable_progress = config.get_disable_progress(&options);
let info_opt = if disable_progress {
None
} else {
let conf = PConfig {
file_count_only: by_filecount,
use_iso: config.get_iso(&options),
ignore_hidden,
};
let info = PIndicator::spawn(conf);
Some(info)
};
let (info_conf, info_data) = if let Some(ref info) = info_opt {
(Some(&info.config), Some(&info.data))
} else {
(None, None)
};
let walk_data = WalkData {
ignore_directories: ignored_full_path,
filter_regex: &filter_regexs,
@@ -172,13 +200,16 @@ fn main() {
allowed_filesystems,
use_apparent_size: config.get_apparent_size(&options),
by_filecount,
ignore_hidden: config.get_ignore_hidden(&options),
ignore_hidden,
follow_links,
progress_config: info_conf,
progress_data: info_data,
};
let _rayon = init_rayon();
let iso = config.get_iso(&options);
let (top_level_nodes, has_errors) = walk_it(simplified_dirs, walk_data);
let tree = match summarize_file_types {
true => get_all_file_types(&top_level_nodes, number_of_lines),
false => {
@@ -194,9 +225,14 @@ fn main() {
}
};
if let Some(info) = info_opt {
info.stop();
}
if has_errors {
eprintln!("Did not have permissions for all directories");
}
if let Some(root_node) = tree {
draw_it(
config.get_full_paths(&options),