Manage symlink into the file ordering

This commit is contained in:
Peltoche 2018-11-25 16:37:30 +01:00
parent 1c852cab1c
commit 95306a0b05
No known key found for this signature in database
GPG key ID: CED68D0487156952
2 changed files with 6 additions and 6 deletions

View file

@ -1,5 +1,5 @@
use formatter::*;
use meta::Meta;
use meta::{Meta, Type};
use std::cmp::Ordering;
use std::path::Path;
use term_grid::{Cell, Direction, Filling, Grid, GridOptions};
@ -190,11 +190,11 @@ impl<'a> Core<'a> {
}
fn sort_by_meta(a: &Meta, b: &Meta) -> Ordering {
if a.path.is_dir() == b.path.is_dir() {
a.path.cmp(&b.path)
} else if a.path.is_dir() && b.path.is_file() {
if a.node_type == Type::Directory && b.node_type != Type::Directory {
Ordering::Less
} else {
} else if b.node_type == Type::Directory && a.node_type != Type::Directory {
Ordering::Greater
} else {
a.path.cmp(&b.path)
}
}

View file

@ -16,7 +16,7 @@ pub enum MetaError {
UnreadableMetadatas { path: String, err: io::Error },
}
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum Type {
SymLink(String),
File,