diff options
author | Thomas Hurst <tom@hur.st> | 2020-07-01 20:28:38 +0000 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-02 06:44:12 +0800 |
commit | 1d8ba524ac83a0c3b5e4146cf937ed75650f1e97 (patch) | |
tree | 82852377479372a176a8b5491dea22e999b6ec6b /src/interactive | |
parent | c37ee449f32ed3af0fc222f669ae3f40859d8a39 (diff) |
Use u128 for byte sizes
Per issue #58, u64 is insufficient for use with very large sparse files.
Enormous file sizes are also a common filesystem error trope, either
from disk corruption or software bugs, and they're also conceivable with
virtual filesystems.
Handle this as gracefully as can be reasonably expected using 128-bit
integers, which should be sufficient for most uses.
Diffstat (limited to 'src/interactive')
-rw-r--r-- | src/interactive/app_test/utils.rs | 4 | ||||
-rw-r--r-- | src/interactive/widgets/entries.rs | 2 | ||||
-rw-r--r-- | src/interactive/widgets/footer.rs | 2 | ||||
-rw-r--r-- | src/interactive/widgets/mark.rs | 4 |
4 files changed, 6 insertions, 6 deletions
diff --git a/src/interactive/app_test/utils.rs b/src/interactive/app_test/utils.rs index 57854d9..ed94720 100644 --- a/src/interactive/app_test/utils.rs +++ b/src/interactive/app_test/utils.rs @@ -33,7 +33,7 @@ pub fn node_by_name(app: &TerminalApp, name: impl AsRef<OsStr>) -> &EntryData { pub fn index_by_name_and_size( app: &TerminalApp, name: impl AsRef<OsStr>, - size: Option<u64>, + size: Option<u128>, ) -> TreeIndex { let name = name.as_ref(); let t: Vec<_> = app @@ -276,7 +276,7 @@ pub fn sample_02_tree() -> Tree { pub fn make_add_node<'a>( t: &'a mut Tree, -) -> impl FnMut(&str, u64, Option<NodeIndex>) -> NodeIndex + 'a { +) -> impl FnMut(&str, u128, Option<NodeIndex>) -> NodeIndex + 'a { move |name, size, maybe_from_idx| { let n = t.add_node(EntryData { name: PathBuf::from(name), diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs index fc68f44..279a7fa 100644 --- a/src/interactive/widgets/entries.rs +++ b/src/interactive/widgets/entries.rs @@ -60,7 +60,7 @@ impl Entries { .is_none() }; - let total: u64 = entries.iter().map(|b| b.data.size).sum(); + let total: u128 = entries.iter().map(|b| b.data.size).sum(); let title = match path_of(tree, *root).to_string_lossy().to_string() { ref p if p.is_empty() => Path::new(".") .canonicalize() diff --git a/src/interactive/widgets/footer.rs b/src/interactive/widgets/footer.rs index 461580c..190c6c9 100644 --- a/src/interactive/widgets/footer.rs +++ b/src/interactive/widgets/footer.rs @@ -11,7 +11,7 @@ use tui::{ pub struct Footer; pub struct FooterProps { - pub total_bytes: Option<u64>, + pub total_bytes: Option<u128>, pub entries_traversed: u64, pub format: ByteFormat, pub message: Option<String>, diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index 1f59738..3c26a3a 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -31,7 +31,7 @@ pub enum MarkMode { pub type EntryMarkMap = BTreeMap<TreeIndex, EntryMark>; pub struct EntryMark { - pub size: u64, + pub size: u128, pub path: PathBuf, pub index: usize, pub num_errors_during_deletion: usize, @@ -230,7 +230,7 @@ impl MarkPane { let title = format!( "Marked {} items ({}) ", marked.len(), - format.display(marked.iter().map(|(_k, v)| v.size).sum::<u64>()) + format.display(marked.iter().map(|(_k, v)| v.size).sum::<u128>()) ); let selected = self.selected; let has_focus = self.has_focus; |