summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hurst <tom@hur.st>2020-03-23 18:31:38 +0000
committerSebastian Thiel <sebastian.thiel@icloud.com>2020-03-24 06:25:41 +0800
commitcf902dbc2cc7b80b2657cf2429db708cc71b6253 (patch)
tree307449036662f7fd93adad75d1c02fc4b430ddea
parent45d1ef31181cd9b430d855a4fe23550ea97e685e (diff)
Update to filesize v0.2
-rw-r--r--Cargo.lock4
-rw-r--r--Cargo.toml2
-rw-r--r--src/aggregate.rs3
-rw-r--r--src/interactive/app_test/utils.rs3
-rw-r--r--src/traverse.rs9
5 files changed, 11 insertions, 10 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 21e2d48..a4870e8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -242,9 +242,9 @@ dependencies = [
[[package]]
name = "filesize"
-version = "0.1.0"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3a941e39ae509cebcd46c6734c20553a9a209b92cea5fc54618fe778fea61701"
+checksum = "12d741e2415d4e2e5bd1c1d00409d1a8865a57892c2d689b504365655d237d43"
dependencies = [
"winapi",
]
diff --git a/Cargo.toml b/Cargo.toml
index 8fc9628..46668f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/src/aggregate.rs b/src/aggregate.rs
index 414a9c0..1da708c 100644
--- a/src/aggregate.rs
+++ b/src/aggregate.rs
@@ -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;
@@ -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
diff --git a/src/interactive/app_test/utils.rs b/src/interactive/app_test/utils.rs
index ca9841c..1aa1a8c 100644
--- a/src/interactive/app_test/utils.rs
+++ b/src/interactive/app_test/utils.rs
@@ -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,
@@ -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,
});
diff --git a/src/traverse.rs b/src/traverse.rs
index 064fcd4..4b73147 100644
--- a/src/traverse.rs
+++ b/src/traverse.rs
@@ -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
@@ -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))
@@ -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;