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| {
|
.filter_map(|d| {
|
||||||
let n = walk(
|
let n = walk(
|
||||||
d,
|
d,
|
||||||
|
false,
|
||||||
&permissions_flag,
|
&permissions_flag,
|
||||||
&ignore_directories,
|
&ignore_directories,
|
||||||
use_apparent_size,
|
use_apparent_size,
|
||||||
@@ -74,6 +75,7 @@ fn clean_inodes(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: check for filesystem too
|
||||||
fn ignore_file(
|
fn ignore_file(
|
||||||
entry: &DirEntry,
|
entry: &DirEntry,
|
||||||
ignore_hidden: bool,
|
ignore_hidden: bool,
|
||||||
@@ -86,6 +88,7 @@ fn ignore_file(
|
|||||||
|
|
||||||
fn walk(
|
fn walk(
|
||||||
dir: PathBuf,
|
dir: PathBuf,
|
||||||
|
is_symlink: bool,
|
||||||
permissions_flag: &AtomicBool,
|
permissions_flag: &AtomicBool,
|
||||||
ignore_directories: &HashSet<PathBuf>,
|
ignore_directories: &HashSet<PathBuf>,
|
||||||
use_apparent_size: bool,
|
use_apparent_size: bool,
|
||||||
@@ -111,6 +114,7 @@ fn walk(
|
|||||||
if data.is_dir() && !data.is_symlink() {
|
if data.is_dir() && !data.is_symlink() {
|
||||||
return walk(
|
return walk(
|
||||||
entry.path(),
|
entry.path(),
|
||||||
|
data.is_symlink(),
|
||||||
permissions_flag,
|
permissions_flag,
|
||||||
ignore_directories,
|
ignore_directories,
|
||||||
use_apparent_size,
|
use_apparent_size,
|
||||||
@@ -122,6 +126,7 @@ fn walk(
|
|||||||
entry.path(),
|
entry.path(),
|
||||||
vec![],
|
vec![],
|
||||||
use_apparent_size,
|
use_apparent_size,
|
||||||
|
data.is_symlink(),
|
||||||
by_filecount,
|
by_filecount,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -135,7 +140,7 @@ fn walk(
|
|||||||
} else {
|
} else {
|
||||||
permissions_flag.store(true, atomic::Ordering::Relaxed);
|
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 {
|
mod tests {
|
||||||
|
|||||||
+9
-1
@@ -15,11 +15,19 @@ pub fn build_node(
|
|||||||
dir: PathBuf,
|
dir: PathBuf,
|
||||||
children: Vec<Node>,
|
children: Vec<Node>,
|
||||||
use_apparent_size: bool,
|
use_apparent_size: bool,
|
||||||
|
is_symlink: bool,
|
||||||
by_filecount: bool,
|
by_filecount: bool,
|
||||||
) -> Option<Node> {
|
) -> Option<Node> {
|
||||||
match get_metadata(&dir, use_apparent_size) {
|
match get_metadata(&dir, use_apparent_size) {
|
||||||
Some(data) => {
|
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 {
|
Some(Node {
|
||||||
name: dir,
|
name: dir,
|
||||||
size,
|
size,
|
||||||
|
|||||||
Reference in New Issue
Block a user