Skip to content

Commit df1f2a0

Browse files
committed
feat: Ignore symlinks
1 parent a462b40 commit df1f2a0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod utils;
99
mod walk;
1010

1111
fn main() {
12-
let CliArgs { path, buf_size } = dbg!(parse_cli_args());
12+
let CliArgs { path, buf_size } = parse_cli_args();
1313

1414
let mut buf = vec![0u8; buf_size];
1515

src/walk.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ pub struct ReadSizes {
1313
}
1414

1515
pub fn read_path<P: AsRef<Path>>(path: P, buf: &mut Vec<u8>) -> ReadSizes {
16-
let metadata = fs::metadata(&path).unwrap();
16+
let metadata = fs::symlink_metadata(&path).unwrap();
1717
if metadata.is_dir() {
1818
read_directory(&path, buf)
1919
} else if metadata.is_file() {
2020
read_file(&path, buf)
21+
} else if metadata.is_symlink() {
22+
eprintln!("Ignoring symlink {:?}", path.as_ref());
23+
ReadSizes {
24+
metadata_size: 0,
25+
actual_size: 0,
26+
}
2127
} else {
2228
eprintln!(
2329
"Error: {:?} has unsupported file type. Only directories and plain files.",

0 commit comments

Comments
 (0)