mirror of
https://github.com/bobwen-dev/hunter
synced 2025-04-12 00:55:41 +02:00
show correct file size
This commit is contained in:
parent
89ffedad18
commit
1826fced28
11
src/files.rs
11
src/files.rs
@ -61,7 +61,7 @@ impl Files {
|
|||||||
let kind = get_kind(&file);
|
let kind = get_kind(&file);
|
||||||
let path = file.path();
|
let path = file.path();
|
||||||
let meta = file.metadata().unwrap();
|
let meta = file.metadata().unwrap();
|
||||||
let size = meta.len() / 1024;
|
let size = meta.len();
|
||||||
let mtime = meta.modified().unwrap();
|
let mtime = meta.modified().unwrap();
|
||||||
|
|
||||||
let color = get_color(&path, &meta);
|
let color = get_color(&path, &meta);
|
||||||
@ -203,7 +203,7 @@ impl File {
|
|||||||
|
|
||||||
let kind = Kind::Directory; //get_kind(&path);
|
let kind = Kind::Directory; //get_kind(&path);
|
||||||
let meta = &path.metadata().unwrap();
|
let meta = &path.metadata().unwrap();
|
||||||
let size = meta.len() / 1024;
|
let size = meta.len();
|
||||||
let mtime = meta.modified().unwrap();
|
let mtime = meta.modified().unwrap();
|
||||||
let color = get_color(&path, meta);
|
let color = get_color(&path, meta);
|
||||||
Ok(File::new(&name, pathbuf, kind, size as usize, mtime, color))
|
Ok(File::new(&name, pathbuf, kind, size as usize, mtime, color))
|
||||||
@ -226,9 +226,10 @@ impl File {
|
|||||||
let unit = match unit {
|
let unit = match unit {
|
||||||
0 => "",
|
0 => "",
|
||||||
1 => " KB",
|
1 => " KB",
|
||||||
2 => " GB",
|
2 => " MB",
|
||||||
3 => " TB",
|
3 => " GB",
|
||||||
4 => "wtf are you doing",
|
4 => " TB",
|
||||||
|
5 => " wtf are you doing",
|
||||||
_ => "",
|
_ => "",
|
||||||
}
|
}
|
||||||
.to_string();
|
.to_string();
|
||||||
|
@ -47,7 +47,6 @@ impl Previewer {
|
|||||||
|
|
||||||
//self.threads.install(|| {
|
//self.threads.install(|| {
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
dbg!(&file);
|
|
||||||
match &file.kind {
|
match &file.kind {
|
||||||
Kind::Directory => match Files::new_from_path(&file.path) {
|
Kind::Directory => match Files::new_from_path(&file.path) {
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
|
@ -53,9 +53,10 @@ impl Widget for TextView {
|
|||||||
}
|
}
|
||||||
fn refresh(&mut self) {
|
fn refresh(&mut self) {
|
||||||
let (xsize, ysize) = self.get_size().size();
|
let (xsize, ysize) = self.get_size().size();
|
||||||
let (xpos, ypos) = self.get_position().position();
|
let (xpos, ypos) = self.get_coordinates().position().position();
|
||||||
|
|
||||||
self.buffer = self
|
self.buffer = self.get_clearlist() +
|
||||||
|
&self
|
||||||
.lines
|
.lines
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.take(ysize as usize)
|
.take(ysize as usize)
|
||||||
@ -69,7 +70,7 @@ impl Widget for TextView {
|
|||||||
xsize = xsize as usize
|
xsize = xsize as usize
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect::<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_drawlist(&self) -> String {
|
fn get_drawlist(&self) -> String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user