style(obj): minor fixes

This commit is contained in:
grimhilt 2024-02-29 09:36:52 +01:00
parent 7951ad0520
commit 8ed86a05ea
2 changed files with 0 additions and 12 deletions

View File

@ -33,14 +33,11 @@ pub trait ObjMethods {
pub struct Obj {
name: String,
ref_path: Option<PathBuf>,
obj_path: PathBuf,
obj_type: ObjType,
file_path: PathBuf, // file here is used as both file and directory
relative_file_path: PathBuf,
hash_path: String, // hash of the relative path of the file
//tree: Option<&Tree>,
//blob: Option<&Blob>
}
@ -252,7 +249,6 @@ impl Obj {
fn new() -> Self {
Obj {
name: String::new(),
ref_path: None,
obj_path: PathBuf::new(),
file_path: PathBuf::new(),
obj_type: ObjType::DEFAULT,
@ -278,7 +274,6 @@ impl Obj {
None => String::new(),
Some(name) => name.to_str().unwrap().to_owned()
},
ref_path: None,
obj_path,
obj_type: match path.exists() {
true => match path.is_dir() {
@ -318,7 +313,6 @@ impl Obj {
let obj = Obj {
name: String::from(name),
ref_path: None,
obj_path,
obj_type: match obj_type {
"tree" => ObjType::TREE,
@ -340,7 +334,6 @@ impl Obj {
pub fn from_head() -> Self {
Obj {
name: String::new(),
ref_path: None,
obj_path: head::path(),
obj_type: ObjType::TREE,
file_path: PathBuf::new(),

View File

@ -7,7 +7,6 @@ use std::io::{self, BufRead, BufReader, Write, Lines};
pub struct Tree {
pub obj: Obj,
pub file: Option<File>,
pub buf_reader: Option<BufReader<File>>,
is_head: bool,
}
@ -17,7 +16,6 @@ impl Tree {
pub fn new(obj: Obj) -> Self {
Tree {
obj,
file: None,
buf_reader: None,
is_head: false,
}
@ -26,7 +24,6 @@ impl Tree {
pub fn from_head() -> Self {
Tree {
obj: Obj::from_head(),
file: None,
buf_reader: None,
is_head: true,
}
@ -35,7 +32,6 @@ impl Tree {
pub fn from_path<S>(r_path: S) -> Tree where S: IntoPathBuf {
Tree {
obj: Obj::from_path(r_path.into()),
file: None,
buf_reader: None,
is_head: false,
}
@ -44,7 +40,6 @@ impl Tree {
pub fn read(&mut self) {
if self.buf_reader.is_none() {
if let Ok(file) = File::open(self.get_obj_path()) {
//self.file = Some(file);
self.buf_reader = Some(BufReader::new(file));
// skip first line if is head