Change size of softlinks to 0

Instead of the size of what they point at
This commit is contained in:
andy.boot
2021-07-15 13:44:07 +01:00
parent 42163abb73
commit 3dad7abfb8
2 changed files with 15 additions and 2 deletions
+6 -1
View File
@@ -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
View File
@@ -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,