From 659e8a4ee130d968ef6bfb22159fb547e366f969 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 16:25:52 +0900 Subject: fix(php-shim): fail RecursiveIteratorFileInfo::get_size on a failed stat This is the type Filesystem::directory_size() actually iterates, and it swallowed a failed stat as 0 the same way. PHP's iterator yields \SplFileInfo there, so raise the same \RuntimeException it would. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-php-shim/src/fs.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'crates/shirabe-php-shim/src') diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index 0006020a..26ea1fdf 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -189,10 +189,15 @@ impl RecursiveIteratorFileInfo { self.path.to_string_lossy().into_owned() } - pub fn get_size(&self) -> i64 { - std::fs::metadata(&self.path) - .map(|m| m.len() as i64) - .unwrap_or(0) + pub fn get_size(&self) -> anyhow::Result { + match filesize(&self.path) { + Some(size) => Ok(size), + None => Err(crate::RuntimeException::new(format!( + "SplFileInfo::getSize(): stat failed for {}", + self.path.display() + )) + .into()), + } } fn sub_pathname(&self) -> String { -- cgit v1.3.1-4-g156e