Skip to content

Commit

Permalink
Update to filesize v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Freaky authored and Byron committed Mar 23, 2020
1 parent 45d1ef3 commit cf902db
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ log = "0.4.6"
tui-react = { path = "./tui-react", version = "0.2" }
num_cpus = "1.10.0"
unicode-segmentation = "1.3.0"
filesize = "0.1.0"
filesize = "0.2.0"

[[bin]]
name="dua"
Expand Down
3 changes: 2 additions & 1 deletion src/aggregate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{InodeFilter, WalkOptions, WalkResult};
use failure::Error;
use filesize::PathExt;
use std::borrow::Cow;
use std::{fmt, io, path::Path};
use termion::color;
Expand Down Expand Up @@ -36,7 +37,7 @@ pub fn aggregate(
if options.apparent_size {
m.len()
} else {
filesize::file_real_size_fast(&entry.path(), m).unwrap_or_else(
entry.path().size_on_disk_fast(m).unwrap_or_else(
|_| {
num_errors += 1;
0
Expand Down
3 changes: 1 addition & 2 deletions src/interactive/app_test/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use petgraph::prelude::NodeIndex;
use std::{
env::temp_dir,
ffi::OsStr,
ffi::OsString,
fmt,
fs::{copy, create_dir_all, remove_dir, remove_file},
io::ErrorKind,
Expand Down Expand Up @@ -272,7 +271,7 @@ pub fn make_add_node<'a>(
) -> impl FnMut(&str, u64, Option<NodeIndex>) -> NodeIndex + 'a {
move |name, size, maybe_from_idx| {
let n = t.add_node(EntryData {
name: OsString::from(name),
name: PathBuf::from(name),
size,
metadata_io_error: false,
});
Expand Down
9 changes: 5 additions & 4 deletions src/traverse.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use crate::{get_size_or_panic, InodeFilter, WalkOptions};
use failure::Error;
use filesize::PathExt;
use petgraph::{graph::NodeIndex, stable_graph::StableGraph, Directed, Direction};
use std::{ffi::OsString, path::PathBuf, time::Duration, time::Instant};
use std::{path::PathBuf, time::Duration, time::Instant};

pub type TreeIndex = NodeIndex;
pub type Tree = StableGraph<EntryData, (), Directed>;

#[derive(Eq, PartialEq, Debug, Default, Clone)]
pub struct EntryData {
pub name: OsString,
pub name: PathBuf,
/// The entry's size in bytes. If it's a directory, the size is the aggregated file size of all children
pub size: u64,
/// If set, the item meta-data could not be obtained
Expand Down Expand Up @@ -91,7 +92,7 @@ impl Traversal {
data.name = if entry.depth < 1 {
path.clone().into()
} else {
entry.file_name
entry.file_name.into()
};
let file_size = match entry.client_state {
Some(Ok(ref m))
Expand All @@ -101,7 +102,7 @@ impl Traversal {
if walk_options.apparent_size {
m.len()
} else {
filesize::file_real_size_fast(&data.name, m).unwrap_or_else(
data.name.size_on_disk_fast(m).unwrap_or_else(
|_| {
t.io_errors += 1;
data.metadata_io_error = true;
Expand Down

0 comments on commit cf902db

Please sign in to comment.