mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
style: fix clippy
This commit is contained in:
+4
-4
@@ -269,10 +269,10 @@ pub fn get_config(conf_path: Option<&String>) -> Config {
|
|||||||
None => {
|
None => {
|
||||||
if let Some(home) = directories::BaseDirs::new() {
|
if let Some(home) = directories::BaseDirs::new() {
|
||||||
for path in get_config_locations(home.home_dir()) {
|
for path in get_config_locations(home.home_dir()) {
|
||||||
if path.exists() {
|
if path.exists()
|
||||||
if let Ok(config) = Config::from_config_file(&path) {
|
&& let Ok(config) = Config::from_config_file(&path)
|
||||||
return config;
|
{
|
||||||
}
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-49
@@ -69,12 +69,11 @@ pub fn walk_it(dirs: HashSet<PathBuf>, walk_data: &WalkData) -> Vec<Node> {
|
|||||||
|
|
||||||
// Remove files which have the same inode, we don't want to double count them.
|
// Remove files which have the same inode, we don't want to double count them.
|
||||||
fn clean_inodes(x: Node, inodes: &mut HashSet<(u64, u64)>, walk_data: &WalkData) -> Option<Node> {
|
fn clean_inodes(x: Node, inodes: &mut HashSet<(u64, u64)>, walk_data: &WalkData) -> Option<Node> {
|
||||||
if !walk_data.use_apparent_size {
|
if !walk_data.use_apparent_size
|
||||||
if let Some(id) = x.inode_device {
|
&& let Some(id) = x.inode_device
|
||||||
if !inodes.insert(id) {
|
&& !inodes.insert(id)
|
||||||
return None;
|
{
|
||||||
}
|
return None;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort Nodes so iteration order is predictable
|
// Sort Nodes so iteration order is predictable
|
||||||
@@ -156,10 +155,10 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
|||||||
|
|
||||||
if !walk_data.allowed_filesystems.is_empty() {
|
if !walk_data.allowed_filesystems.is_empty() {
|
||||||
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
||||||
if let Some((_size, Some((_id, dev)), _gunk)) = size_inode_device {
|
if let Some((_size, Some((_id, dev)), _gunk)) = size_inode_device
|
||||||
if !walk_data.allowed_filesystems.contains(&dev) {
|
&& !walk_data.allowed_filesystems.contains(&dev)
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if walk_data.filter_accessed_time.is_some()
|
if walk_data.filter_accessed_time.is_some()
|
||||||
@@ -167,20 +166,19 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
|||||||
|| walk_data.filter_changed_time.is_some()
|
|| walk_data.filter_changed_time.is_some()
|
||||||
{
|
{
|
||||||
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
||||||
if let Some((_, _, (modified_time, accessed_time, changed_time))) = size_inode_device {
|
if let Some((_, _, (modified_time, accessed_time, changed_time))) = size_inode_device
|
||||||
if entry.path().is_file()
|
&& entry.path().is_file()
|
||||||
&& [
|
&& [
|
||||||
(&walk_data.filter_modified_time, modified_time),
|
(&walk_data.filter_modified_time, modified_time),
|
||||||
(&walk_data.filter_accessed_time, accessed_time),
|
(&walk_data.filter_accessed_time, accessed_time),
|
||||||
(&walk_data.filter_changed_time, changed_time),
|
(&walk_data.filter_changed_time, changed_time),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.any(|(filter_time, actual_time)| {
|
.any(|(filter_time, actual_time)| {
|
||||||
is_filtered_out_due_to_file_time(filter_time, *actual_time)
|
is_filtered_out_due_to_file_time(filter_time, *actual_time)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,32 +220,30 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
|||||||
|
|
||||||
// return walk(entry.path(), walk_data, depth)
|
// return walk(entry.path(), walk_data, depth)
|
||||||
|
|
||||||
if !ignore_file(entry, walk_data) {
|
if !ignore_file(entry, walk_data)
|
||||||
if let Ok(data) = entry.file_type() {
|
&& let Ok(data) = entry.file_type()
|
||||||
if data.is_dir()
|
{
|
||||||
|| (walk_data.follow_links && data.is_symlink())
|
if data.is_dir()
|
||||||
{
|
|| (walk_data.follow_links && data.is_symlink())
|
||||||
return walk(entry.path(), walk_data, depth + 1);
|
{
|
||||||
}
|
return walk(entry.path(), walk_data, depth + 1);
|
||||||
|
|
||||||
let node = build_node(
|
|
||||||
entry.path(),
|
|
||||||
vec![],
|
|
||||||
data.is_symlink(),
|
|
||||||
data.is_file(),
|
|
||||||
depth,
|
|
||||||
walk_data,
|
|
||||||
);
|
|
||||||
|
|
||||||
prog_data.num_files.fetch_add(1, ORDERING);
|
|
||||||
if let Some(ref file) = node {
|
|
||||||
prog_data
|
|
||||||
.total_file_size
|
|
||||||
.fetch_add(file.size, ORDERING);
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let node = build_node(
|
||||||
|
entry.path(),
|
||||||
|
vec![],
|
||||||
|
data.is_symlink(),
|
||||||
|
data.is_file(),
|
||||||
|
depth,
|
||||||
|
walk_data,
|
||||||
|
);
|
||||||
|
|
||||||
|
prog_data.num_files.fetch_add(1, ORDERING);
|
||||||
|
if let Some(ref file) = node {
|
||||||
|
prog_data.total_file_size.fetch_add(file.size, ORDERING);
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(ref failed) => {
|
Err(ref failed) => {
|
||||||
|
|||||||
+8
-2
@@ -106,14 +106,20 @@ pub fn test_ignore_all_in_file() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_files_from_flag_file() {
|
pub fn test_files_from_flag_file() {
|
||||||
let output = build_command(vec!["--files-from", "tests/test_dir_files_from/files_from.txt"]);
|
let output = build_command(vec![
|
||||||
|
"--files-from",
|
||||||
|
"tests/test_dir_files_from/files_from.txt",
|
||||||
|
]);
|
||||||
assert!(output.contains("a_file"));
|
assert!(output.contains("a_file"));
|
||||||
assert!(output.contains("hello_file"));
|
assert!(output.contains("hello_file"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_files0_from_flag_file() {
|
pub fn test_files0_from_flag_file() {
|
||||||
let output = build_command(vec!["--files0-from", "tests/test_dir_files_from/files0_from.txt"]);
|
let output = build_command(vec![
|
||||||
|
"--files0-from",
|
||||||
|
"tests/test_dir_files_from/files0_from.txt",
|
||||||
|
]);
|
||||||
assert!(output.contains("a_file"));
|
assert!(output.contains("a_file"));
|
||||||
assert!(output.contains("hello_file"));
|
assert!(output.contains("hello_file"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user