summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2020-07-12 14:09:07 +0200
committerGitHub <noreply@github.com>2020-07-12 14:09:07 +0200
commit12f042b979d9ba6dc79c668cde7f09154b302286 (patch)
tree146d271b75ce100c858c87bdf0480acf4861f3d5
parent94c9cc457609b59387397075552fe32601d32d48 (diff)
feat(filesystem): flag for showing file apparent size (#66)
* feat(filesystem): flag for showing file apparent size * style(format): fmt fmt fmt
-rw-r--r--src/app.rs7
-rw-r--r--src/main.rs13
-rw-r--r--src/state/files/file_or_folder.rs20
-rw-r--r--src/state/files/file_tree.rs9
-rw-r--r--src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_x_as_zero.snap8
-rw-r--r--src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_y_as_zero.snap98
-rw-r--r--src/tests/cases/ui.rs505
7 files changed, 445 insertions, 215 deletions
diff --git a/src/app.rs b/src/app.rs
index 7e6e68c..1405059 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -44,11 +44,16 @@ where
terminal_backend: B,
path_in_filesystem: PathBuf,
event_sender: SyncSender<Event>,
+ show_apparent_size: bool,
) -> Self {
let display = Display::new(terminal_backend);
let board = Board::new(&Folder::new(&path_in_filesystem));
let base_folder = Folder::new(&path_in_filesystem);
- let file_tree = ManuallyDrop::new(FileTree::new(base_folder, path_in_filesystem));
+ let file_tree = ManuallyDrop::new(FileTree::new(
+ base_folder,
+ path_in_filesystem,
+ show_apparent_size,
+ ));
// we use ManuallyDrop here because otherwise the app takes forever to exit
let ui_effects = UiEffects::new();
App {
diff --git a/src/main.rs b/src/main.rs
index c8dc258..e5ac3b5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -49,6 +49,9 @@ pub struct Opt {
#[structopt(name = "folder", parse(from_os_str))]
/// The folder to scan
folder: Option<PathBuf>,
+ #[structopt(short, long)]
+ /// Show file sizes rather than their block usage on disk
+ apparent_size: bool,
}
fn main() {
@@ -71,7 +74,12 @@ fn try_main() -> Result<(), failure::Error> {
if !folder.as_path().is_dir() {
failure::bail!("Folder '{}' does not exist", folder.to_string_lossy())
}
- start(terminal_backend, Box::new(keyboard_events), folder);
+ start(
+ terminal_backend,
+ Box::new(keyboard_events),
+ folder,
+ opts.apparent_size,
+ );
}
Err(_) => failure::bail!("Failed to get stdout: are you trying to pipe 'diskonaut'?"),
}
@@ -82,6 +90,7 @@ pub fn start<B>(
terminal_backend: B,
keyboard_events: Box<dyn Iterator<Item = TermionEvent> + Send>,
path: PathBuf,
+ show_apparent_size: bool,
) where
B: Backend + Send + 'static,
{
@@ -222,7 +231,7 @@ pub fn start<B>(
);
}
- let mut app = App::new(terminal_backend, path, event_sender);
+ let mut app = App::new(terminal_backend, path, event_sender, show_apparent_size);
app.start(instruction_receiver);
running.store(false, Ordering::Release);
cleanup();
diff --git a/src/state/files/file_or_folder.rs b/src/state/files/file_or_folder.rs
index cf976e7..5c5de49 100644
--- a/src/state/files/file_or_folder.rs
+++ b/src/state/files/file_or_folder.rs
@@ -55,13 +55,25 @@ impl Folder {
}
}
- pub fn add_entry(&mut self, entry_metadata: &Metadata, relative_path: PathBuf) {
+ pub fn add_entry(
+ &mut self,
+ entry_metadata: &Metadata,
+ relative_path: PathBuf,
+ show_apparent_size: bool,
+ ) {
+ // apparent_size (named after the flag of the same name in 'du')
+ // means "show the file size, rather than the actual space it takes on disk"
+ // these may differ (for example) in filesystems that use compression
if entry_metadata.is_dir() {
self.add_folder(relative_path);
} else {
- let size = relative_path
- .size_on_disk_fast(&entry_metadata)
- .unwrap_or(entry_metadata.len()) as u128;
+ let size = if show_apparent_size {
+ entry_metadata.len() as u128
+ } else {
+ relative_path
+ .size_on_disk_fast(&entry_metadata)
+ .unwrap_or(entry_metadata.len()) as u128
+ };
self.add_file(relative_path, size);
}
}
diff --git a/src/state/files/file_tree.rs b/src/state/files/file_tree.rs
index fb21b1f..3d2e610 100644
--- a/src/state/files/file_tree.rs
+++ b/src/state/files/file_tree.rs
@@ -6,21 +6,23 @@ use crate::state::files::{FileOrFolder, Folder};
use crate::state::FileToDelete;
pub struct FileTree {
- base_folder: Folder,
pub current_folder_names: Vec<OsString>,
pub space_freed: u128,
pub failed_to_read: u64,
pub path_in_filesystem: PathBuf,
+ base_folder: Folder,
+ show_apparent_size: bool,
}
impl FileTree {
- pub fn new(base_folder: Folder, path_in_filesystem: PathBuf) -> Self {
+ pub fn new(base_folder: Folder, path_in_filesystem: PathBuf, show_apparent_size: bool) -> Self {
FileTree {
base_folder,
current_folder_names: Vec::new(),
path_in_filesystem,
space_freed: 0,
failed_to_read: 0,
+ show_apparent_size,
}
}
pub fn get_total_size(&self) -> u128 {
@@ -73,6 +75,7 @@ impl FileTree {
for dir in entry_full_path.components().skip(base_path_length) {
relative_path.push(dir);
}
- self.base_folder.add_entry(entry_metadata, relative_path);
+ self.base_folder
+ .add_entry(entry_metadata, relative_path, self.show_apparent_size);
}
}
diff --git a/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_x_as_zero.snap b/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_x_as_zero.snap
index a0fbdf0..6629a94 100644
--- a/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_x_as_zero.snap
+++ b/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_x_as_zero.snap
@@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: "&terminal_draw_events_mirror[0]"
---
- 2.3M | /tmp/diskonaut_tes[..]les_with_x_as_zero
+ 2.4M | /tmp/diskonaut_tes[..]les_with_x_as_zero
┌────────────────────────────────────────────────┐
│ │
│ │
@@ -30,8 +30,8 @@ expression: "&terminal_draw_events_mirror[0]"
│ │
│ │
│ │
-│ file2 │
│ │
+│ file2 │
│ │
│ 1.0M (42%) │
│ │
@@ -41,6 +41,7 @@ expression: "&terminal_draw_events_mirror[0]"
│ │
│ │
│ │
+│ │
├────────────────────────────────────────────────┤
│xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
│xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
@@ -48,8 +49,7 @@ expression: "&terminal_draw_events_mirror[0]"
│xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
│xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
│xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
└────────────────────────────────────────────────┘
(x = Small files)
- ←↓↑→/<ENTER>/<ESC>: navigate, <BACKSPACE>: del
+ ←↓↑→/<ENTER>/<ESC>: navigate, <BACKSPACE>: del
diff --git a/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_y_as_zero.snap b/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_y_as_zero.snap
index 76233d0..c277f43 100644
--- a/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_y_as_zero.snap
+++ b/src/tests/cases/snapshots/diskonaut__tests__cases__ui__small_files_with_y_as_zero.snap
@@ -2,54 +2,54 @@
source: src/tests/cases/ui.rs
expression: "&terminal_draw_events_mirror[0]"
---
- Total: 1.3M (100 files), freed: 0 | /tmp/diskonaut_tests/small_files_with_y_as_zero
-┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────┐
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ file1 │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ 1.0M (71%) │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
-└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────┘
+ Total: 1.4M (100 files), freed: 0 | /tmp/diskonaut_tests/small_files_with_y_as_zero
+┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────┐
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ file1 │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ 1.0M (72%) │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+│ │xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx│
+└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────┘
(x = Small files)
- <arrows> - move around, <ENTER> - enter folder, <ESC> - parent folder, <BACKSPACE> - delete, <+/-/0> - zoom in/out/reset, <q> - quit
+ <arrows> - move around, <ENTER> - enter folder, <ESC> - parent folder, <BACKSPACE> - delete, <+/-/0> - zoom in/out/reset, <q> - quit
diff --git a/src/tests/cases/ui.rs b/src/tests/cases/ui.rs
index fad8418..1560000 100644
--- a/src/tests/cases/ui.rs
+++ b/src/tests/cases/ui.rs
@@ -12,6 +12,12 @@ use crate::tests::cases::test_utils::{sleep_and_quit_events, test_backend_factor
use crate::tests::fakes::KeyboardEvents;
use crate::tests::fakes::TerminalEvent::*;
+// this means we ask diskonaut to show the actual file size rather than the size taken on disk
+//
+// this is in order to make the tests more possible, so they will show the same result
+// on filesystems with and without compression
+const SHOW_APPARENT_SIZE: bool = true;
+
fn create_root_temp_dir(name: &str) -> Result<PathBuf, failure::Error> {
let mut dir = PathBuf::new();
dir.push(String::from("/tmp/diskonaut_tests")); // TODO: fix this for other platforms
@@ -44,17 +50,22 @@ fn two_large_files_one_small_file() {
let mut file_1_path = PathBuf::from(&temp_dir_path);
file_1_path.push("file1");
- create_temp_file(file_1_path, 4000).expect("failed to create temp file");
+ create_temp_file(file_1_path, 4096).expect("failed to create temp file");
let mut file_2_path = PathBuf::from(&temp_dir_path);
file_2_path.push("file2");
- create_temp_file(file_2_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_2_path, 8192).expect("failed to create temp file");
let mut file_3_path = PathBuf::from(&temp_dir_path);
file_3_path.push("file3");
- create_temp_file(file_3_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_3_path, 8192).expect("failed to create temp file");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -84,17 +95,22 @@ fn medium_width() {
let mut file_1_path = PathBuf::from(&temp_dir_path);
file_1_path.push("file1");
- create_temp_file(file_1_path, 4000).expect("failed to create temp file");
+ create_temp_file(file_1_path, 4096).expect("failed to create temp file");
let mut file_2_path = PathBuf::from(&temp_dir_path);
file_2_path.push("file2");
- create_temp_file(file_2_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_2_path, 8192).expect("failed to create temp file");
let mut file_3_path = PathBuf::from(&temp_dir_path);
file_3_path.push("file3");
- create_temp_file(file_3_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_3_path, 8192).expect("failed to create temp file");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -124,17 +140,22 @@ fn small_width() {
let mut file_1_path = PathBuf::from(&temp_dir_path);
file_1_path.push("file1");
- create_temp_file(file_1_path, 4000).expect("failed to create temp file");
+ create_temp_file(file_1_path, 4096).expect("failed to create temp file");
let mut file_2_path = PathBuf::from(&temp_dir_path);
file_2_path.push("file2");
- create_temp_file(file_2_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_2_path, 8192).expect("failed to create temp file");
let mut file_3_path = PathBuf::from(&temp_dir_path);
file_3_path.push("file3");
- create_temp_file(file_3_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_3_path, 8192).expect("failed to create temp file");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -165,17 +186,22 @@ fn small_width_long_folder_name() {
let mut file_1_path = PathBuf::from(&temp_dir_path);
file_1_path.push("file1");
- create_temp_file(file_1_path, 4000).expect("failed to create temp file");
+ create_temp_file(file_1_path, 4096).expect("failed to create temp file");
let mut file_2_path = PathBuf::from(&temp_dir_path);
file_2_path.push("file2");
- create_temp_file(file_2_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_2_path, 8192).expect("failed to create temp file");
let mut file_3_path = PathBuf::from(&temp_dir_path);
file_3_path.push("file3");
- create_temp_file(file_3_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_3_path, 8192).expect("failed to create temp file");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -206,17 +232,22 @@ fn too_small_width_one() {
let mut file_1_path = PathBuf::from(&temp_dir_path);
file_1_path.push("file1");
- create_temp_file(file_1_path, 4000).expect("failed to create temp file");
+ create_temp_file(file_1_path, 4096).expect("failed to create temp file");
let mut file_2_path = PathBuf::from(&temp_dir_path);
file_2_path.push("file2");
- create_temp_file(file_2_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_2_path, 8192).expect("failed to create temp file");
let mut file_3_path = PathBuf::from(&temp_dir_path);
file_3_path.push("file3");
- create_temp_file(file_3_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_3_path, 8192).expect("failed to create temp file");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -244,17 +275,22 @@ fn too_small_width_two() {
let mut file_1_path = PathBuf::from(&temp_dir_path);
file_1_path.push("file1");
- create_temp_file(file_1_path, 4000).expect("failed to create temp file");
+ create_temp_file(file_1_path, 4096).expect("failed to create temp file");
let mut file_2_path = PathBuf::from(&temp_dir_path);
file_2_path.push("file2");
- create_temp_file(file_2_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_2_path, 8192).expect("failed to create temp file");
let mut file_3_path = PathBuf::from(&temp_dir_path);
file_3_path.push("file3");
- create_temp_file(file_3_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_3_path, 8192).expect("failed to create temp file");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -280,7 +316,12 @@ fn too_small_width_three() {
let temp_dir_path =
create_root_temp_dir("too_small_width_three").expect("failed to create temp dir");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -306,7 +347,12 @@ fn too_small_width_four() {
let temp_dir_path =
create_root_temp_dir("too_small_width_four").expect("failed to create temp dir");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -332,7 +378,12 @@ fn too_small_width_five() {
let temp_dir_path =
create_root_temp_dir("too_small_width_five").expect("failed to create temp dir");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -358,7 +409,12 @@ fn too_small_height() {
let temp_dir_path =
create_root_temp_dir("too_small_height").expect("failed to create temp dir");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw_events.lock().unwrap();
println!(
@@ -385,49 +441,54 @@ fn eleven_files() {
let mut file_1_path = PathBuf::from(&temp_dir_path);
file_1_path.push("file1");
- create_temp_file(file_1_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_1_path, 8192).expect("failed to create temp file");
let mut file_2_path = PathBuf::from(&temp_dir_path);
file_2_path.push("file2");
- create_temp_file(file_2_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_2_path, 8192).expect("failed to create temp file");
let mut file_3_path = PathBuf::from(&temp_dir_path);
file_3_path.push("file3");
- create_temp_file(file_3_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_3_path, 8192).expect("failed to create temp file");
let mut file_4_path = PathBuf::from(&temp_dir_path);
file_4_path.push("file4");
- create_temp_file(file_4_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_4_path, 8192).expect("failed to create temp file");
let mut file_5_path = PathBuf::from(&temp_dir_path);
file_5_path.push("file5");
- create_temp_file(file_5_path, 5000).expect("failed to create temp file");
+ create_temp_file(file_5_path, 8192).expect("failed to create temp file");
let mut file_6_path = PathBuf::from(&temp_dir_path);
file_6_path.push("file6");
- create_temp_file(file_6_path, 50000).expect("failed to create temp file");
+ create_temp_file(file_6_path, 53248).expect("failed to create temp file");
let mut file_7_path = PathBuf::from(&temp_dir_path);
file_7_path.push("file7");
- create_temp_file(file_7_path, 150000).expect("failed to create temp file");
+ create_temp_file(file_7_path, 151552).expect("failed to create temp file");
let mut file_8_path = PathBuf::from(&temp_dir_path);
file_8_path.push("file8");
- create_temp_file(file_8_path, 50000).expect("failed to create temp file");
+ create_temp_file(file_8_path, 53248).expect("failed to create temp file");
let mut file_9_path = PathBuf::from(&temp_dir_path);
file_9_path.push("file9");
- create_temp_file(file_9_path, 50000).expect("failed to create temp file");
+ create_temp_file(file_9_path, 53248).expect("failed to create temp file");
let mut file_10_path = PathBuf::from(&temp_dir_path);
file_10_path.push("file10");
- create_temp_file(file_10_path, 50000).expect("failed to create temp file");
+ create_temp_file(file_10_path, 53248).expect("failed to create temp file");
let mut file_11_path = PathBuf::from(&temp_dir_path);
file_11_path.push("file11");
- create_temp_file(file_11_path, 50000).expect("failed to create temp file");
+ create_temp_file(file_11_path, 53248).expect("failed to create temp file");
- start(backend, keyboard_events, temp_dir_path.clone());
+ start(
+ backend,
+ keyboard_events,
+ temp_dir_path.clone(),
+ SHOW_APPARENT_SIZE,
+ );
std::fs::remove_dir_all(temp_dir_path).expect("failed to remove temporary folder");
let terminal_draw_events_mirror = terminal_draw