aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package/comparer
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
commita1c7e6908a26e10f6e1f23a51721664b5e2d838d (patch)
treec575c76f1b43359ed74913da4c6a2636643f1ba0 /crates/shirabe/src/package/comparer
parent7f606f36fef0c0467c3c0db3d0da33af486dae8a (diff)
downloadphp-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.gz
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.zst
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.zip
chore(style): cargo fmt
Diffstat (limited to 'crates/shirabe/src/package/comparer')
-rw-r--r--crates/shirabe/src/package/comparer/comparer.rs30
-rw-r--r--crates/shirabe/src/package/comparer/mod.rs1
2 files changed, 25 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);
}
diff --git a/crates/shirabe/src/package/comparer/mod.rs b/crates/shirabe/src/package/comparer/mod.rs
new file mode 100644
index 0000000..4c5c6d2
--- /dev/null
+++ b/crates/shirabe/src/package/comparer/mod.rs
@@ -0,0 +1 @@
+pub mod comparer;