Guest User

Untitled

a guest
Jun 18th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. WalkDir::new(&config.backup_path)
  2. .min_depth(1)
  3. .into_iter()
  4. .filter_map(|e| e.ok())
  5. .filter(|e| e.path().is_file())
  6. .for_each(|e| {
  7. let remote_path: Vec<String> = e.path()
  8. .strip_prefix(&config.backup_path)
  9. .unwrap()
  10. .iter()
  11. .map(|e| OsStr::to_string_lossy(e).into_owned())
  12. .collect();
  13. let path = e.path().to_path_buf();
  14. let backup_file = OpenOptions::new()
  15. .read(true)
  16. .open(e.path())
  17. .context(format!(
  18. "Failed to open file for some reason, path: {}.",
  19. e.path().display()
  20. ))
  21. .unwrap();
  22.  
  23. match lookup_file.get(&path) {
  24. Some(entry) => {
  25. let hash = hash_file(&backup_file, &hasher).to_vec();
  26.  
  27. if entry.hash != hash {
  28. nlookup.remove(&path);
  29. let nentry = Entry::new(hash, remote_path);
  30. nlookup.insert(path, nentry);
  31. }
  32. }
  33. None => {
  34. let hash = hash_file(&backup_file, &hasher);
  35. /*
  36. let entry = Entry::new(
  37. lookup_file.insert(path, entry);*/
  38. }
  39. }
Add Comment
Please, Sign In to add comment