Skip to content

Commit

Permalink
fix typo Operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Its-Just-Nans authored and bootandy committed Jan 15, 2025
1 parent 1372815 commit bfe7323
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
override: true
profile: minimal # minimal component installation (ie, no documentation)
components: rustfmt, clippy
- name: typos-action
uses: crate-ci/[email protected]
- name: "`fmt` testing"
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
uses: actions-rs/cargo@v1
Expand Down
18 changes: 9 additions & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::io::IsTerminal;
use std::path::Path;
use std::path::PathBuf;

use crate::dir_walker::Operater;
use crate::dir_walker::Operator;
use crate::display::get_number_format;

pub static DAY_SECONDS: i64 = 24 * 60 * 60;
Expand Down Expand Up @@ -160,21 +160,21 @@ impl Config {
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(
options.get_one::<String>("mtime"),
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(
options.get_one::<String>("atime"),
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(
options.get_one::<String>("ctime"),
get_current_date_epoch_seconds(),
Expand All @@ -183,7 +183,7 @@ impl Config {
}

fn get_current_date_epoch_seconds() -> i64 {
// calcurate current date epoch seconds
// calculate current date epoch seconds
let now = Local::now();
let current_date = now.date_naive();

Expand All @@ -197,7 +197,7 @@ fn get_current_date_epoch_seconds() -> i64 {
fn get_filter_time_operator(
option_value: Option<&String>,
current_date_epoch_seconds: i64,
) -> Option<(Operater, i64)> {
) -> Option<(Operator, i64)> {
match option_value {
Some(val) => {
let time = current_date_epoch_seconds
Expand All @@ -207,9 +207,9 @@ fn get_filter_time_operator(
.abs()
* DAY_SECONDS;
match val.chars().next().expect("Value should not be empty") {
'+' => Some((Operater::LessThan, time - DAY_SECONDS)),
'-' => Some((Operater::GreaterThan, time)),
_ => Some((Operater::Equal, time - DAY_SECONDS)),
'+' => Some((Operator::LessThan, time - DAY_SECONDS)),
'-' => Some((Operator::GreaterThan, time)),
_ => Some((Operator::Equal, time - DAY_SECONDS)),
}
}
None => None,
Expand Down
14 changes: 7 additions & 7 deletions src/dir_walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::node::FileTime;
use crate::platform::get_metadata;

#[derive(Debug)]
pub enum Operater {
pub enum Operator {
Equal = 0,
LessThan = 1,
GreaterThan = 2,
Expand All @@ -36,9 +36,9 @@ pub struct WalkData<'a> {
pub filter_regex: &'a [Regex],
pub invert_filter_regex: &'a [Regex],
pub allowed_filesystems: HashSet<u64>,
pub filter_modified_time: Option<(Operater, i64)>,
pub filter_accessed_time: Option<(Operater, i64)>,
pub filter_changed_time: Option<(Operater, i64)>,
pub filter_modified_time: Option<(Operator, i64)>,
pub filter_accessed_time: Option<(Operator, i64)>,
pub filter_changed_time: Option<(Operator, i64)>,
pub use_apparent_size: bool,
pub by_filecount: bool,
pub by_filetime: &'a Option<FileTime>,
Expand Down Expand Up @@ -300,9 +300,9 @@ mod tests {
filter_regex: &[],
invert_filter_regex: &[],
allowed_filesystems: HashSet::new(),
filter_modified_time: Some((Operater::GreaterThan, 0)),
filter_accessed_time: Some((Operater::GreaterThan, 0)),
filter_changed_time: Some((Operater::GreaterThan, 0)),
filter_modified_time: Some((Operator::GreaterThan, 0)),
filter_accessed_time: Some((Operator::GreaterThan, 0)),
filter_changed_time: Some((Operator::GreaterThan, 0)),
use_apparent_size,
by_filecount: false,
by_filetime: &None,
Expand Down
10 changes: 5 additions & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};

use crate::config::DAY_SECONDS;

use crate::dir_walker::Operater;
use crate::dir_walker::Operator;
use crate::platform;
use regex::Regex;

Expand Down Expand Up @@ -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(
filter_time: &Option<(Operater, i64)>,
filter_time: &Option<(Operator, i64)>,
actual_time: i64,
) -> bool {
match filter_time {
None => false,
Some((Operater::Equal, bound_time)) => {
Some((Operator::Equal, bound_time)) => {
!(actual_time >= *bound_time && actual_time < *bound_time + DAY_SECONDS)
}
Some((Operater::GreaterThan, bound_time)) => actual_time < *bound_time,
Some((Operater::LessThan, bound_time)) => actual_time > *bound_time,
Some((Operator::GreaterThan, bound_time)) => actual_time < *bound_time,
Some((Operator::LessThan, bound_time)) => actual_time > *bound_time,
}
}

Expand Down

0 comments on commit bfe7323

Please sign in to comment.