mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
fix typo Operator
This commit is contained in:
@@ -45,6 +45,8 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
profile: minimal # minimal component installation (ie, no documentation)
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
- name: typos-action
|
||||||
|
uses: crate-ci/typos@v1.28.4
|
||||||
- name: "`fmt` testing"
|
- name: "`fmt` testing"
|
||||||
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
|
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
|
|||||||
+9
-9
@@ -8,7 +8,7 @@ use std::io::IsTerminal;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::dir_walker::Operater;
|
use crate::dir_walker::Operator;
|
||||||
use crate::display::get_number_format;
|
use crate::display::get_number_format;
|
||||||
|
|
||||||
pub static DAY_SECONDS: i64 = 24 * 60 * 60;
|
pub static DAY_SECONDS: i64 = 24 * 60 * 60;
|
||||||
@@ -160,21 +160,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) -> Option<(Operator, 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) -> Option<(Operator, 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_changed_time_operator(&self, options: &ArgMatches) -> Option<(Operater, i64)> {
|
pub fn get_changed_time_operator(&self, options: &ArgMatches) -> Option<(Operator, 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(),
|
||||||
@@ -183,7 +183,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_date_epoch_seconds() -> i64 {
|
fn get_current_date_epoch_seconds() -> i64 {
|
||||||
// calcurate current date epoch seconds
|
// calculate current date epoch seconds
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
let current_date = now.date_naive();
|
let current_date = now.date_naive();
|
||||||
|
|
||||||
@@ -197,7 +197,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)> {
|
) -> Option<(Operator, i64)> {
|
||||||
match option_value {
|
match option_value {
|
||||||
Some(val) => {
|
Some(val) => {
|
||||||
let time = current_date_epoch_seconds
|
let time = current_date_epoch_seconds
|
||||||
@@ -207,9 +207,9 @@ 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)),
|
'+' => Some((Operator::LessThan, time - DAY_SECONDS)),
|
||||||
'-' => Some((Operater::GreaterThan, time)),
|
'-' => Some((Operator::GreaterThan, time)),
|
||||||
_ => Some((Operater::Equal, time - DAY_SECONDS)),
|
_ => Some((Operator::Equal, time - DAY_SECONDS)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
|
|||||||
+7
-7
@@ -25,7 +25,7 @@ use crate::node::FileTime;
|
|||||||
use crate::platform::get_metadata;
|
use crate::platform::get_metadata;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Operater {
|
pub enum Operator {
|
||||||
Equal = 0,
|
Equal = 0,
|
||||||
LessThan = 1,
|
LessThan = 1,
|
||||||
GreaterThan = 2,
|
GreaterThan = 2,
|
||||||
@@ -36,9 +36,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: Option<(Operator, i64)>,
|
||||||
pub filter_accessed_time: Option<(Operater, i64)>,
|
pub filter_accessed_time: Option<(Operator, i64)>,
|
||||||
pub filter_changed_time: Option<(Operater, i64)>,
|
pub filter_changed_time: Option<(Operator, i64)>,
|
||||||
pub use_apparent_size: bool,
|
pub use_apparent_size: bool,
|
||||||
pub by_filecount: bool,
|
pub by_filecount: bool,
|
||||||
pub by_filetime: &'a Option<FileTime>,
|
pub by_filetime: &'a Option<FileTime>,
|
||||||
@@ -300,9 +300,9 @@ mod tests {
|
|||||||
filter_regex: &[],
|
filter_regex: &[],
|
||||||
invert_filter_regex: &[],
|
invert_filter_regex: &[],
|
||||||
allowed_filesystems: HashSet::new(),
|
allowed_filesystems: HashSet::new(),
|
||||||
filter_modified_time: Some((Operater::GreaterThan, 0)),
|
filter_modified_time: Some((Operator::GreaterThan, 0)),
|
||||||
filter_accessed_time: Some((Operater::GreaterThan, 0)),
|
filter_accessed_time: Some((Operator::GreaterThan, 0)),
|
||||||
filter_changed_time: Some((Operater::GreaterThan, 0)),
|
filter_changed_time: Some((Operator::GreaterThan, 0)),
|
||||||
use_apparent_size,
|
use_apparent_size,
|
||||||
by_filecount: false,
|
by_filecount: false,
|
||||||
by_filetime: &None,
|
by_filetime: &None,
|
||||||
|
|||||||
+5
-5
@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
|
|||||||
|
|
||||||
use crate::config::DAY_SECONDS;
|
use crate::config::DAY_SECONDS;
|
||||||
|
|
||||||
use crate::dir_walker::Operater;
|
use crate::dir_walker::Operator;
|
||||||
use crate::platform;
|
use crate::platform;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
@@ -78,16 +78,16 @@ 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: &Option<(Operater, i64)>,
|
filter_time: &Option<(Operator, i64)>,
|
||||||
actual_time: i64,
|
actual_time: i64,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match filter_time {
|
match filter_time {
|
||||||
None => false,
|
None => false,
|
||||||
Some((Operater::Equal, bound_time)) => {
|
Some((Operator::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,
|
Some((Operator::GreaterThan, bound_time)) => actual_time < *bound_time,
|
||||||
Some((Operater::LessThan, bound_time)) => actual_time > *bound_time,
|
Some((Operator::LessThan, bound_time)) => actual_time > *bound_time,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user