diff options
Diffstat (limited to 'crates/shirabe/src/package/comparer/comparer.rs')
| -rw-r--r-- | crates/shirabe/src/package/comparer/comparer.rs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/crates/shirabe/src/package/comparer/comparer.rs b/crates/shirabe/src/package/comparer/comparer.rs index 8f7f312..0e0d295 100644 --- a/crates/shirabe/src/package/comparer/comparer.rs +++ b/crates/shirabe/src/package/comparer/comparer.rs @@ -81,17 +81,26 @@ impl Comparer { let dest_file_hash = destination.get(dir).and_then(|d| d.get(file)); if let Some(dest_hash) = dest_file_hash { if hash != dest_hash { - self.changed.entry("changed".to_string()).or_default().push(format!("{}/{}", dir, file)); + self.changed + .entry("changed".to_string()) + .or_default() + .push(format!("{}/{}", dir, file)); } } else { - self.changed.entry("removed".to_string()).or_default().push(format!("{}/{}", dir, file)); + self.changed + .entry("removed".to_string()) + .or_default() + .push(format!("{}/{}", dir, file)); } } } for (dir, value) in &destination { for (file, _hash) in value { if !source.get(dir).map_or(false, |d| d.contains_key(file)) { - self.changed.entry("added".to_string()).or_default().push(format!("{}/{}", dir, file)); + self.changed + .entry("added".to_string()) + .or_default() + .push(format!("{}/{}", dir, file)); } } } @@ -106,8 +115,13 @@ impl Comparer { } let path = format!("{}/{}", dir, file); if Path::new(&path).is_symlink() { - let link_target = std::fs::read_link(&path).ok().and_then(|p| p.to_str().map(|s| s.to_string())); - array.entry(dir.to_string()).or_default().insert(file, link_target); + let link_target = std::fs::read_link(&path) + .ok() + .and_then(|p| p.to_str().map(|s| s.to_string())); + array + .entry(dir.to_string()) + .or_default() + .insert(file, link_target); } else if Path::new(&path).is_dir() { if array.is_empty() { array.insert("0".to_string(), IndexMap::new()); @@ -118,7 +132,11 @@ impl Comparer { } else if Path::new(&path).is_file() { let size = std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0); if size > 0 { - let algo = if shirabe_php_shim::PHP_VERSION_ID > 80100 { "xxh3" } else { "sha1" }; + let algo = if shirabe_php_shim::PHP_VERSION_ID > 80100 { + "xxh3" + } else { + "sha1" + }; let hash = shirabe_php_shim::hash_file(algo, &path); array.entry(dir.to_string()).or_default().insert(file, hash); } |
