Skip to content

Commit

Permalink
fix regression for flag -a from #245
Browse files Browse the repository at this point in the history
  • Loading branch information
meain authored and Peltoche committed Jul 31, 2019
1 parent 939aba8 commit ffcadc1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub use self::symlink::SymLink;
pub use crate::flags::Display;
pub use crate::icon::Icons;

use std::fs;
use std::fs::read_link;
use std::io::{Error, ErrorKind};
use std::path::PathBuf;
Expand Down Expand Up @@ -72,7 +73,8 @@ impl Meta {
let mut current_meta;
let mut parent_meta;

let parent_path = match self.path.parent() {
let absolute_path = fs::canonicalize(&self.path)?;
let parent_path = match absolute_path.parent() {
None => PathBuf::from("/"),
Some(path) => PathBuf::from(path),
};
Expand Down Expand Up @@ -124,15 +126,16 @@ impl Meta {
}

pub fn calculate_total_size(&mut self) {
if let FileType::Directory{ uid: _ } = self.file_type {
if let FileType::Directory { uid: _ } = self.file_type {
if let Some(metas) = &mut self.content {
let mut size_accumulated = self.size.get_bytes();
for x in &mut metas.iter_mut() {
x.calculate_total_size();
size_accumulated += x.size.get_bytes();
}
self.size = Size::new(size_accumulated);
} else { // possibility that 'depth' limited the recursion in 'recurse_into'
} else {
// possibility that 'depth' limited the recursion in 'recurse_into'
self.size = Size::new(Meta::calculate_total_file_size(&self.path));
}
}
Expand Down Expand Up @@ -177,8 +180,7 @@ impl Meta {
size += Meta::calculate_total_file_size(&path);
}
size
}
else {
} else {
0
}
}
Expand Down

0 comments on commit ffcadc1

Please sign in to comment.