v0.2
This commit is contained in:
@@ -20,38 +20,26 @@ async fn walk_dir(dir: String) -> HashMap<String, FileInfo> {
|
|||||||
for e in WalkDir::new(&dir) {
|
for e in WalkDir::new(&dir) {
|
||||||
let e = e.unwrap();
|
let e = e.unwrap();
|
||||||
let path = e.path();
|
let path = e.path();
|
||||||
println!(
|
|
||||||
"Path: {}, {}",
|
|
||||||
path.display(),
|
|
||||||
path.display().to_string().eq(&dir)
|
|
||||||
);
|
|
||||||
if path.display().to_string().eq(&dir) {
|
if path.display().to_string().eq(&dir) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let content: Vec<u8>;
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
let path_str = path.display().to_string();
|
let path_str = path.display().to_string();
|
||||||
let hash = get_hash(path_str.clone().into_bytes()).await;
|
content = path_str.into_bytes();
|
||||||
let file_info = FileInfo {
|
|
||||||
relative_path: path_str[dir.len() + 1..].to_string(),
|
|
||||||
path: path_str,
|
|
||||||
hash: hash.clone(),
|
|
||||||
is_dir: true,
|
|
||||||
};
|
|
||||||
hash_list.entry(hash).or_insert(file_info);
|
|
||||||
} else {
|
} else {
|
||||||
let content = fs::read(path).unwrap();
|
content = fs::read(path).unwrap();
|
||||||
let hash = get_hash(content).await;
|
|
||||||
let path_str = path.display().to_string();
|
|
||||||
let file_info = FileInfo {
|
|
||||||
relative_path: path_str[dir.len() + 1..].to_string(),
|
|
||||||
path: path_str,
|
|
||||||
hash: hash.clone(),
|
|
||||||
is_dir: false,
|
|
||||||
};
|
|
||||||
hash_list.entry(hash).or_insert(file_info);
|
|
||||||
}
|
}
|
||||||
|
let hash = get_hash(content).await;
|
||||||
|
let path_str = path.display().to_string();
|
||||||
|
let file_info = FileInfo {
|
||||||
|
relative_path: path_str[dir.len() + 1..].to_string(),
|
||||||
|
path: path_str,
|
||||||
|
hash: hash.clone(),
|
||||||
|
is_dir: path.is_dir(),
|
||||||
|
};
|
||||||
|
hash_list.entry(hash).or_insert(file_info);
|
||||||
}
|
}
|
||||||
println!("{:?}", hash_list);
|
|
||||||
hash_list
|
hash_list
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +65,6 @@ async fn compare_hashes(old: HashMap<String, FileInfo>, new: HashMap<String, Fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
if new_fileinfo.is_dir {
|
if new_fileinfo.is_dir {
|
||||||
println!("{}", new_fileinfo.is_dir);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user