Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "findutils"
version = "0.11.0"
homepage = "https://github.com/uutils/findutils"
repository = "https://github.com/uutils/findutils"
edition = "2021"
edition = "2024"
rust-version = "1.88.0"
license = "MIT"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions benches/find_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::time::SystemTime;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use findutils::find::{find_main, Dependencies};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use findutils::find::{Dependencies, find_main};

/// `Dependencies` implementation that throws output away. A fixed `now` keeps
/// time-based matchers (`-newer`, `-mtime`, …) deterministic across runs.
Expand Down
2 changes: 1 addition & 1 deletion benches/locate_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
mod bench {
use std::path::{Path, PathBuf};

use criterion::{black_box, criterion_group, Criterion};
use criterion::{Criterion, black_box, criterion_group};
use findutils::locate::locate_main;
use findutils::updatedb::updatedb_main;

Expand Down
2 changes: 1 addition & 1 deletion benches/updatedb_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use std::path::{Path, PathBuf};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use findutils::updatedb::updatedb_main;

/// Run `updatedb` end-to-end. `args` are the arguments after the program name.
Expand Down
2 changes: 1 addition & 1 deletion benches/xargs_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use std::path::PathBuf;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use findutils::xargs::xargs_main;

/// Run `xargs` end-to-end. `args` are the arguments after the program name.
Expand Down
4 changes: 2 additions & 2 deletions src/find/matchers/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

use std::fs;
use std::io::{self, stderr, Write};
use std::io::{self, Write, stderr};

use super::{Matcher, MatcherIO, WalkEntry};

Expand Down Expand Up @@ -57,7 +57,7 @@ impl Matcher for DeleteMatcher {

#[cfg(test)]
mod tests {
use std::fs::{create_dir, File};
use std::fs::{File, create_dir};
use tempfile::Builder;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion src/find/matchers/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::{
fs::read_dir,
io::{stderr, Write},
io::{Write, stderr},
};

use super::{Matcher, MatcherIO, WalkEntry};
Expand Down
16 changes: 8 additions & 8 deletions src/find/matchers/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ impl WalkEntry {
}
Err(e) if e.is_not_found() => {
// Detect broken symlinks and replace them with explicit entries
if let (Some(path), Some(depth)) = (e.path(), e.depth()) {
if let Ok(meta) = path.symlink_metadata() {
return Ok(Self {
inner: Entry::Explicit(path.into(), depth),
follow: Follow::Never,
meta: Ok(meta).into(),
});
}
if let (Some(path), Some(depth)) = (e.path(), e.depth())
&& let Ok(meta) = path.symlink_metadata()
{
return Ok(Self {
inner: Entry::Explicit(path.into(), depth),
follow: Follow::Never,
meta: Ok(meta).into(),
});
}

Err(e)
Expand Down
2 changes: 1 addition & 1 deletion src/find/matchers/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::cell::RefCell;
use std::error::Error;
use std::ffi::{OsStr, OsString};
use std::io::{stderr, Write};
use std::io::{Write, stderr};
use std::path::Path;
use std::process::Command;

Expand Down
14 changes: 7 additions & 7 deletions src/find/matchers/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Cache {
#[cfg(unix)]
use std::{
cell::RefCell,
io::{stderr, Write},
io::{Write, stderr},
path::Path,
};

Expand All @@ -54,10 +54,10 @@ pub fn get_file_system_type(path: &Path, cache: &RefCell<Option<Cache>>) -> URes
/// This is only supported on Unix.
#[cfg(unix)]
pub fn fs_type_for_dev(dev_id: String, cache: &RefCell<Option<Cache>>) -> UResult<String> {
if let Some(cache) = cache.borrow().as_ref() {
if cache.dev_id == dev_id {
return Ok(cache.fs_type.clone());
}
if let Some(cache) = cache.borrow().as_ref()
&& cache.dev_id == dev_id
{
return Ok(cache.fs_type.clone());
}

let fs_list = uucore::fsext::read_fs_list()?;
Expand Down Expand Up @@ -148,9 +148,9 @@ mod tests {
fn test_fs_matcher() {
use crate::find::{
matchers::{
fs::{get_file_system_type, Cache},
tests::get_dir_entry_for,
Matcher,
fs::{Cache, get_file_system_type},
tests::get_dir_entry_for,
},
tests::FakeDependencies,
};
Expand Down
2 changes: 1 addition & 1 deletion src/find/matchers/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mod tests {
#[test]
#[cfg(unix)]
fn test_group_matcher() {
use crate::find::matchers::{group::GroupMatcher, tests::get_dir_entry_for, Matcher};
use crate::find::matchers::{Matcher, group::GroupMatcher, tests::get_dir_entry_for};
use crate::find::tests::FakeDependencies;
use chrono::Local;
use nix::unistd::{Gid, Group};
Expand Down
2 changes: 1 addition & 1 deletion src/find/matchers/lname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

use std::io::{stderr, Write};
use std::io::{Write, stderr};
use std::path::PathBuf;

use super::glob::Pattern;
Expand Down
7 changes: 3 additions & 4 deletions src/find/matchers/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use chrono::DateTime;
use std::{
fs::File,
io::{stderr, Write},
io::{Write, stderr},
};

use super::{Matcher, MatcherIO, StdoutErrors, WalkEntry};
Expand Down Expand Up @@ -87,12 +87,11 @@ impl Ls {
now_utc.format("%b %e %H:%M")
};
let mut path = file_info.path().to_string_lossy().into_owned();
if file_info.file_type().is_symlink() {
if let Ok(target) = std::fs::read_link(file_info.path()) {
if file_info.file_type().is_symlink()
&& let Ok(target) = std::fs::read_link(file_info.path()) {
path.push_str(" -> ");
path.push_str(&target.to_string_lossy());
}
}

match writeln!(
out,
Expand Down
Loading
Loading