step ten: hash the files

This commit is contained in:
Gonçalo Valério 2020-10-05 19:32:48 +01:00
parent 97f9c41bc9
commit cbf02e6bc2
1 changed files with 4 additions and 1 deletions

View File

@ -1,4 +1,6 @@
use std::fs;
#[path = "data.rs"]
mod data;
pub fn write_tree(directory: String) {
let entries = fs::read_dir(&directory).unwrap();
@ -14,7 +16,8 @@ pub fn write_tree(directory: String) {
}
if metadata.is_file() {
println!("{}", full);
let hash = data::hash_object(&fs::read(&full).unwrap(), "blob".to_owned());
println!("{} {}", hash, full);
} else if metadata.is_dir() {
write_tree(full);
}