Skip to content

Commit

Permalink
Let's just say we compute the aggregate correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sebastian Thiel committed Jun 1, 2019
1 parent 04f50bd commit 61ca52a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
28 changes: 4 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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};
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/success-no-arguments
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1258947 .
1259683 .

0 comments on commit 61ca52a

Please sign in to comment.