Compare commits

..

1 Commits

Author SHA1 Message Date
andy.boot 3428c5c35c version: increment version 2024-07-05 21:17:45 +01:00
9 changed files with 48 additions and 66 deletions
Generated
+1 -1
View File
@@ -303,7 +303,7 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]] [[package]]
name = "du-dust" name = "du-dust"
version = "1.1.1" version = "1.0.0"
dependencies = [ dependencies = [
"ansi_term", "ansi_term",
"assert_cmd", "assert_cmd",
+1 -1
View File
@@ -1,7 +1,7 @@
[package] [package]
name = "du-dust" name = "du-dust"
description = "A more intuitive version of du" description = "A more intuitive version of du"
version = "1.1.1" version = "1.1.0"
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"] authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
+4 -11
View File
@@ -1,21 +1,14 @@
# ----------- To do a release --------- # ----------- To do a release ---------
# ----------- Pre release ---------
# Compare times of runs to check no drastic slow down: # Compare times of runs to check no drastic slow down:
# hyperfine 'target/release/dust /home/andy' # time target/release/dust ~/dev
# hyperfine 'dust /home/andy' # time dust ~dev
# ----------- Release ---------
# inc version in cargo.toml
# cargo build --release
# commit changed files
# merge to master in github
# edit version in cargo.toml
# tag a commit and push (increment version in Cargo.toml first): # tag a commit and push (increment version in Cargo.toml first):
# git tag v0.4.5 # git tag v0.4.5
# git push origin v0.4.5 # git push origin v0.4.5
# cargo publish to put it in crates.io # cargo publish to put it in crates.io
# Optional: To install locally # To install locally [Do before pushing it]
#cargo install --path . #cargo install --path .
+2 -2
View File
@@ -1,6 +1,6 @@
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.TH Dust 1 "Dust 1.1.1" .TH Dust 1 "Dust 1.0.0"
.SH NAME .SH NAME
Dust \- Like du but more intuitive Dust \- Like du but more intuitive
.SH SYNOPSIS .SH SYNOPSIS
@@ -124,4 +124,4 @@ Print version
[\fIPATH\fR] [\fIPATH\fR]
.SH VERSION .SH VERSION
v1.1.1 v1.0.0
+8 -8
View File
@@ -145,21 +145,21 @@ impl Config {
Some(true) == self.output_json || options.get_flag("output_json") Some(true) == self.output_json || options.get_flag("output_json")
} }
pub fn get_modified_time_operator(&self, options: &ArgMatches) -> Option<(Operater, i64)> { pub fn get_modified_time_operator(&self, options: &ArgMatches) -> (Operater, i64) {
get_filter_time_operator( get_filter_time_operator(
options.get_one::<String>("mtime"), options.get_one::<String>("mtime"),
get_current_date_epoch_seconds(), get_current_date_epoch_seconds(),
) )
} }
pub fn get_accessed_time_operator(&self, options: &ArgMatches) -> Option<(Operater, i64)> { pub fn get_accessed_time_operator(&self, options: &ArgMatches) -> (Operater, i64) {
get_filter_time_operator( get_filter_time_operator(
options.get_one::<String>("atime"), options.get_one::<String>("atime"),
get_current_date_epoch_seconds(), get_current_date_epoch_seconds(),
) )
} }
pub fn get_created_time_operator(&self, options: &ArgMatches) -> Option<(Operater, i64)> { pub fn get_created_time_operator(&self, options: &ArgMatches) -> (Operater, i64) {
get_filter_time_operator( get_filter_time_operator(
options.get_one::<String>("ctime"), options.get_one::<String>("ctime"),
get_current_date_epoch_seconds(), get_current_date_epoch_seconds(),
@@ -182,7 +182,7 @@ fn get_current_date_epoch_seconds() -> i64 {
fn get_filter_time_operator( fn get_filter_time_operator(
option_value: Option<&String>, option_value: Option<&String>,
current_date_epoch_seconds: i64, current_date_epoch_seconds: i64,
) -> Option<(Operater, i64)> { ) -> (Operater, i64) {
match option_value { match option_value {
Some(val) => { Some(val) => {
let time = current_date_epoch_seconds let time = current_date_epoch_seconds
@@ -192,12 +192,12 @@ fn get_filter_time_operator(
.abs() .abs()
* DAY_SECONDS; * DAY_SECONDS;
match val.chars().next().expect("Value should not be empty") { match val.chars().next().expect("Value should not be empty") {
'+' => Some((Operater::LessThan, time - DAY_SECONDS)), '+' => (Operater::LessThan, time - DAY_SECONDS),
'-' => Some((Operater::GreaterThan, time)), '-' => (Operater::GreaterThan, time),
_ => Some((Operater::Equal, time - DAY_SECONDS)), _ => (Operater::Equal, time - DAY_SECONDS),
} }
} }
None => None, None => (Operater::GreaterThan, 0),
} }
} }
+23 -29
View File
@@ -35,9 +35,9 @@ pub struct WalkData<'a> {
pub filter_regex: &'a [Regex], pub filter_regex: &'a [Regex],
pub invert_filter_regex: &'a [Regex], pub invert_filter_regex: &'a [Regex],
pub allowed_filesystems: HashSet<u64>, pub allowed_filesystems: HashSet<u64>,
pub filter_modified_time: Option<(Operater, i64)>, pub filter_modified_time: (Operater, i64),
pub filter_accessed_time: Option<(Operater, i64)>, pub filter_accessed_time: (Operater, i64),
pub filter_changed_time: Option<(Operater, i64)>, pub filter_changed_time: (Operater, i64),
pub use_apparent_size: bool, pub use_apparent_size: bool,
pub by_filecount: bool, pub by_filecount: bool,
pub ignore_hidden: bool, pub ignore_hidden: bool,
@@ -116,33 +116,27 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
let is_dot_file = entry.file_name().to_str().unwrap_or("").starts_with('.'); let is_dot_file = entry.file_name().to_str().unwrap_or("").starts_with('.');
let is_ignored_path = walk_data.ignore_directories.contains(&entry.path()); let is_ignored_path = walk_data.ignore_directories.contains(&entry.path());
if !walk_data.allowed_filesystems.is_empty() { let size_inode_device = get_metadata(entry.path(), false);
let size_inode_device = get_metadata(entry.path(), false); if let Some((_size, Some((_id, dev)), (modified_time, accessed_time, changed_time))) =
if let Some((_size, Some((_id, dev)), _gunk)) = size_inode_device { size_inode_device
if !walk_data.allowed_filesystems.contains(&dev) {
return true;
}
}
}
if walk_data.filter_accessed_time.is_some()
|| walk_data.filter_modified_time.is_some()
|| walk_data.filter_changed_time.is_some()
{ {
let size_inode_device = get_metadata(entry.path(), false); if !walk_data.allowed_filesystems.is_empty()
if let Some((_, _, (modified_time, accessed_time, changed_time))) = size_inode_device { && !walk_data.allowed_filesystems.contains(&dev)
if entry.path().is_file() {
&& [ return true;
(&walk_data.filter_modified_time, modified_time), }
(&walk_data.filter_accessed_time, accessed_time), if entry.path().is_file()
(&walk_data.filter_changed_time, changed_time), && [
] (&walk_data.filter_modified_time, modified_time),
.iter() (&walk_data.filter_accessed_time, accessed_time),
.any(|(filter_time, actual_time)| { (&walk_data.filter_changed_time, changed_time),
is_filtered_out_due_to_file_time(filter_time, *actual_time) ]
}) .iter()
{ .any(|(filter_time, actual_time)| {
return true; is_filtered_out_due_to_file_time(filter_time, *actual_time)
} })
{
return true;
} }
} }
+3 -3
View File
@@ -114,7 +114,7 @@ fn recursive_rebuilder(allowed_nodes: &HashMap<&Path, &Node>, current: &Node) ->
.map(|c| recursive_rebuilder(allowed_nodes, c)) .map(|c| recursive_rebuilder(allowed_nodes, c))
.collect(); .collect();
build_display_node(new_children, current) build_node(new_children, current)
} }
// Applies all allowed nodes as children to current node // Applies all allowed nodes as children to current node
@@ -127,10 +127,10 @@ fn flat_rebuilder(allowed_nodes: HashMap<&Path, &Node>, current: &Node) -> Displ
children: vec![], children: vec![],
}) })
.collect::<Vec<DisplayNode>>(); .collect::<Vec<DisplayNode>>();
build_display_node(new_children, current) build_node(new_children, current)
} }
fn build_display_node(mut new_children: Vec<DisplayNode>, current: &Node) -> DisplayNode { fn build_node(mut new_children: Vec<DisplayNode>, current: &Node) -> DisplayNode {
new_children.sort_by(|lhs, rhs| lhs.cmp(rhs).reverse()); new_children.sort_by(|lhs, rhs| lhs.cmp(rhs).reverse());
DisplayNode { DisplayNode {
name: current.name.clone(), name: current.name.clone(),
+4 -8
View File
@@ -65,17 +65,13 @@ pub fn is_filtered_out_due_to_regex(filter_regex: &[Regex], dir: &Path) -> bool
} }
} }
pub fn is_filtered_out_due_to_file_time( pub fn is_filtered_out_due_to_file_time(filter_time: &(Operater, i64), actual_time: i64) -> bool {
filter_time: &Option<(Operater, i64)>,
actual_time: i64,
) -> bool {
match filter_time { match filter_time {
None => false, (Operater::Equal, bound_time) => {
Some((Operater::Equal, bound_time)) => {
!(actual_time >= *bound_time && actual_time < *bound_time + DAY_SECONDS) !(actual_time >= *bound_time && actual_time < *bound_time + DAY_SECONDS)
} }
Some((Operater::GreaterThan, bound_time)) => actual_time < *bound_time, (Operater::GreaterThan, bound_time) => actual_time < *bound_time,
Some((Operater::LessThan, bound_time)) => actual_time > *bound_time, (Operater::LessThan, bound_time) => actual_time > *bound_time,
} }
} }
+1 -2
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::process::Output; use std::process::Output;
use std::sync::Once; use std::sync::Once;
use std::{io, str}; use std::{fs, io, str};
static INIT: Once = Once::new(); static INIT: Once = Once::new();
static UNREADABLE_DIR_PATH: &str = "/tmp/unreadable_dir"; static UNREADABLE_DIR_PATH: &str = "/tmp/unreadable_dir";
@@ -38,7 +38,6 @@ fn copy_test_data(dir: &str) {
fn create_unreadable_directory() -> io::Result<()> { fn create_unreadable_directory() -> io::Result<()> {
#[cfg(unix)] #[cfg(unix)]
{ {
use std::fs;
use std::fs::Permissions; use std::fs::Permissions;
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
fs::create_dir_all(UNREADABLE_DIR_PATH)?; fs::create_dir_all(UNREADABLE_DIR_PATH)?;