Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WalkDir::new(&config.backup_path)
- .min_depth(1)
- .into_iter()
- .filter_map(|e| e.ok())
- .filter(|e| e.path().is_file())
- .for_each(|e| {
- let remote_path: Vec<String> = e.path()
- .strip_prefix(&config.backup_path)
- .unwrap()
- .iter()
- .map(|e| OsStr::to_string_lossy(e).into_owned())
- .collect();
- let path = e.path().to_path_buf();
- let backup_file = OpenOptions::new()
- .read(true)
- .open(e.path())
- .context(format!(
- "Failed to open file for some reason, path: {}.",
- e.path().display()
- ))
- .unwrap();
- match lookup_file.get(&path) {
- Some(entry) => {
- let hash = hash_file(&backup_file, &hasher).to_vec();
- if entry.hash != hash {
- nlookup.remove(&path);
- let nentry = Entry::new(hash, remote_path);
- nlookup.insert(path, nentry);
- }
- }
- None => {
- let hash = hash_file(&backup_file, &hasher);
- /*
- let entry = Entry::new(
- lookup_file.insert(path, entry);*/
- }
- }
Add Comment
Please, Sign In to add comment