How to get a file's real size?

Ok so the reason it was returning wrong values was because I'm just plain stupid.

Basically I do something like:

WalkDir::new(source).into_iter().map(|item| item.metadata().unwrap().len())

Except I was writing this:

WalkDir::new(source).into_iter().map(|item| source.metadata().unwrap().len())

See the little source instead of item before .metadata()? The code compiled correctly but I was getting the size of the source directory, which is by convention a cluster's size :man_facepalming:

So problem solved, thank you all for helping and sorry for wasting your time :pray:

15 Likes