mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Change size of softlinks to 0
Instead of the size of what they point at
This commit is contained in:
+6
-1
@@ -27,6 +27,7 @@ pub fn walk_it(
|
||||
.filter_map(|d| {
|
||||
let n = walk(
|
||||
d,
|
||||
false,
|
||||
&permissions_flag,
|
||||
&ignore_directories,
|
||||
use_apparent_size,
|
||||
@@ -74,6 +75,7 @@ fn clean_inodes(
|
||||
});
|
||||
}
|
||||
|
||||
// todo: check for filesystem too
|
||||
fn ignore_file(
|
||||
entry: &DirEntry,
|
||||
ignore_hidden: bool,
|
||||
@@ -86,6 +88,7 @@ fn ignore_file(
|
||||
|
||||
fn walk(
|
||||
dir: PathBuf,
|
||||
is_symlink: bool,
|
||||
permissions_flag: &AtomicBool,
|
||||
ignore_directories: &HashSet<PathBuf>,
|
||||
use_apparent_size: bool,
|
||||
@@ -111,6 +114,7 @@ fn walk(
|
||||
if data.is_dir() && !data.is_symlink() {
|
||||
return walk(
|
||||
entry.path(),
|
||||
data.is_symlink(),
|
||||
permissions_flag,
|
||||
ignore_directories,
|
||||
use_apparent_size,
|
||||
@@ -122,6 +126,7 @@ fn walk(
|
||||
entry.path(),
|
||||
vec![],
|
||||
use_apparent_size,
|
||||
data.is_symlink(),
|
||||
by_filecount,
|
||||
);
|
||||
}
|
||||
@@ -135,7 +140,7 @@ fn walk(
|
||||
} else {
|
||||
permissions_flag.store(true, atomic::Ordering::Relaxed);
|
||||
}
|
||||
build_node(dir, children, use_apparent_size, by_filecount)
|
||||
build_node(dir, children, use_apparent_size, is_symlink, by_filecount)
|
||||
}
|
||||
|
||||
mod tests {
|
||||
|
||||
+9
-1
@@ -15,11 +15,19 @@ pub fn build_node(
|
||||
dir: PathBuf,
|
||||
children: Vec<Node>,
|
||||
use_apparent_size: bool,
|
||||
is_symlink: bool,
|
||||
by_filecount: bool,
|
||||
) -> Option<Node> {
|
||||
match get_metadata(&dir, use_apparent_size) {
|
||||
Some(data) => {
|
||||
let (size, inode_device) = if by_filecount { (1, data.1) } else { data };
|
||||
let (size, inode_device) = if by_filecount {
|
||||
(1, data.1)
|
||||
} else if is_symlink && !use_apparent_size {
|
||||
(0, None)
|
||||
} else {
|
||||
data
|
||||
};
|
||||
|
||||
Some(Node {
|
||||
name: dir,
|
||||
size,
|
||||
|
||||
Reference in New Issue
Block a user