mirror of
https://github.com/bootandy/dust.git
synced 2025-12-16 09:30:48 -08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d00519085a | ||
|
|
04b80b474c |
600
Cargo.lock
generated
600
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
13
Cargo.toml
@@ -28,10 +28,10 @@ strip = true
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.12"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
lscolors = "0.21"
|
||||
terminal_size = "0.4"
|
||||
unicode-width = "0.2"
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
lscolors = "0.13"
|
||||
terminal_size = "0.2"
|
||||
unicode-width = "0.1"
|
||||
rayon = "1"
|
||||
thousands = "0.2"
|
||||
stfu8 = "0.2"
|
||||
@@ -39,8 +39,9 @@ regex = "1"
|
||||
config-file = "0.2"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
sysinfo = "0.37"
|
||||
ctrlc = "3"
|
||||
directories = "4"
|
||||
sysinfo = "0.27"
|
||||
ctrlc = "3.4"
|
||||
chrono = "0.4"
|
||||
|
||||
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||
|
||||
@@ -244,7 +244,7 @@ fn convert_min_size(input: &str) -> Option<usize> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_config_locations(base: PathBuf) -> Vec<PathBuf> {
|
||||
fn get_config_locations(base: &Path) -> Vec<PathBuf> {
|
||||
vec![
|
||||
base.join(".dust.toml"),
|
||||
base.join(".config").join("dust").join("config.toml"),
|
||||
@@ -267,8 +267,8 @@ pub fn get_config(conf_path: Option<&String>) -> Config {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(home) = std::env::home_dir() {
|
||||
for path in get_config_locations(home) {
|
||||
if let Some(home) = directories::BaseDirs::new() {
|
||||
for path in get_config_locations(home.home_dir()) {
|
||||
if path.exists()
|
||||
&& let Ok(config) = Config::from_config_file(&path)
|
||||
{
|
||||
|
||||
@@ -403,7 +403,7 @@ fn get_pretty_name(
|
||||
.ls_colors
|
||||
.style_for_path_with_metadata(&node.name, meta_result.as_ref().ok());
|
||||
let ansi_style = directory_color
|
||||
.map(Style::to_nu_ansi_term_style)
|
||||
.map(Style::to_ansi_term_style)
|
||||
.unwrap_or_default();
|
||||
let out = ansi_style.paint(name_and_padding);
|
||||
format!("{out}")
|
||||
@@ -439,9 +439,6 @@ pub fn get_number_format(output_str: &str) -> Option<(u64, char)> {
|
||||
}
|
||||
|
||||
pub fn human_readable_number(size: u64, output_str: &str) -> String {
|
||||
if output_str == "count" {
|
||||
return size.to_string();
|
||||
};
|
||||
match get_number_format(output_str) {
|
||||
Some((x, u)) => {
|
||||
format!("{}{}", (size / x), u)
|
||||
@@ -542,13 +539,6 @@ mod tests {
|
||||
assert_eq!(s, "short 3 4.0K 100%");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_machine_readable_filecount() {
|
||||
assert_eq!(human_readable_number(1, "count"), "1");
|
||||
assert_eq!(human_readable_number(1000, "count"), "1000");
|
||||
assert_eq!(human_readable_number(1024, "count"), "1024");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_human_readable_number() {
|
||||
assert_eq!(human_readable_number(1, ""), "1B");
|
||||
|
||||
14
src/main.rs
14
src/main.rs
@@ -29,7 +29,7 @@ use std::panic;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use sysinfo::System;
|
||||
use sysinfo::{System, SystemExt};
|
||||
use utils::canonicalize_absolute_path;
|
||||
|
||||
use self::display::draw_it;
|
||||
@@ -319,11 +319,7 @@ fn print_output(
|
||||
|
||||
if config.get_output_json(&options) {
|
||||
OUTPUT_TYPE.with(|wrapped| {
|
||||
if by_filecount {
|
||||
wrapped.replace("count".to_string());
|
||||
} else {
|
||||
wrapped.replace(output_format);
|
||||
}
|
||||
wrapped.replace(output_format);
|
||||
});
|
||||
println!("{}", serde_json::to_string(&tree).unwrap());
|
||||
} else {
|
||||
@@ -440,10 +436,10 @@ fn init_rayon(stack: &Option<usize>, threads: &Option<usize>) -> rayon::ThreadPo
|
||||
None
|
||||
} else {
|
||||
let large_stack = usize::pow(1024, 3);
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_memory();
|
||||
let mut s = System::new();
|
||||
s.refresh_memory();
|
||||
// Larger stack size if possible to handle cases with lots of nested directories
|
||||
let available = sys.available_memory();
|
||||
let available = s.available_memory();
|
||||
if available > (large_stack * threads.unwrap_or(1)).try_into().unwrap() {
|
||||
Some(large_stack)
|
||||
} else {
|
||||
|
||||
@@ -62,8 +62,6 @@ fn initialize() {
|
||||
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
|
||||
initialize();
|
||||
let mut to_run = &mut Command::cargo_bin("dust").unwrap();
|
||||
// Hide progress bar
|
||||
to_run.arg("-P");
|
||||
for p in command_args {
|
||||
to_run = to_run.arg(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user