summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-06-01 11:26:14 +0530
committerSebastian Thiel <sthiel@thoughtworks.com>2019-06-01 11:26:14 +0530
commit61ca52a2a8b23daffc3eea1fe8d71078e757a0d3 (patch)
tree2323d3dfb51c235c68831ad1be9a84f9ffc48bbe
parent04f50bdcdbe995e7d9952788eb4cc4f736299c39 (diff)
Let's just say we compute the aggregate correctly
Might have to look at the link handling again, for now it seems it does not follow symlinks anyway, so our computation should be correct.
-rw-r--r--src/lib.rs28
-rw-r--r--src/main.rs3
-rw-r--r--tests/snapshots/success-no-arguments2
3 files changed, 6 insertions, 27 deletions
diff --git a/src/lib.rs b/src/lib.rs
index b0cadeb..3535952 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -25,29 +25,10 @@ impl fmt::Display for WalkResult {
}
}
-pub fn file_size_no_symlink_follow(meta: &fs::Metadata) -> u64 {
- match meta.file_type().is_symlink() {
- // true => sys::symlink_size(meta),
- true => unimplemented!("{} {}", sys::symlink_size(meta), meta.len()),
- false => meta.len(),
- }
-}
-
-#[cfg(target_os = "macos")]
-mod sys {
- use std::fs::Metadata;
- use std::os::macos::fs::MetadataExt;
-
- pub fn symlink_size(meta: &Metadata) -> u64 {
- meta.st_size()
- }
-}
-
mod aggregate {
- use crate::{file_size_no_symlink_follow, WalkOptions, WalkResult};
+ use crate::{WalkOptions, WalkResult};
use failure::Error;
- use std::io;
- use std::path::Path;
+ use std::{io, path::Path};
pub fn aggregate(
mut out: impl io::Write,
@@ -61,7 +42,7 @@ mod aggregate {
match entry {
Ok(entry) => {
num_bytes += match entry.metadata {
- Some(Ok(m)) => file_size_no_symlink_follow(&m),
+ Some(Ok(m)) => m.len(),
Some(Err(_)) => {
res.num_errors += 1;
0
@@ -83,5 +64,4 @@ mod aggregate {
pub use aggregate::aggregate;
use jwalk::WalkDir;
-use std::path::Path;
-use std::{fmt, fs};
+use std::{fmt, path::Path};
diff --git a/src/main.rs b/src/main.rs
index 73a9f28..11f0670 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,8 +5,7 @@ extern crate structopt;
use failure::Error;
use failure_tools::ok_or_exit;
-use std::io;
-use std::path::PathBuf;
+use std::{io, path::PathBuf};
use structopt::StructOpt;
mod options {
diff --git a/tests/snapshots/success-no-arguments b/tests/snapshots/success-no-arguments
index f8b55b8..d47bfb4 100644
--- a/tests/snapshots/success-no-arguments
+++ b/tests/snapshots/success-no-arguments
@@ -1 +1 @@
-1258947 .
+1259683 . \ No newline at end of file