From 264feb1093d587e5df457fac023852a0e578b22f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 10 Aug 2026 02:59:50 +0900 Subject: fix(php-shim): return an error from fileperms instead of 0 fileperms swallowed metadata errors and reported a mode of 0, which the callers could not tell apart from a real (if implausible) mode: the zip archiver stored entries with no permission bits, and Filesystem::copy chmod-ed the target to 0. It now returns Result so both callers propagate the failure. The switch to u32 also drops the casts around the mode arithmetic and ZipArchive's entry attributes. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-symfony-filesystem/src/filesystem.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/shirabe-symfony-filesystem/src') diff --git a/crates/shirabe-symfony-filesystem/src/filesystem.rs b/crates/shirabe-symfony-filesystem/src/filesystem.rs index 737c3bea..0bb54efd 100644 --- a/crates/shirabe-symfony-filesystem/src/filesystem.rs +++ b/crates/shirabe-symfony-filesystem/src/filesystem.rs @@ -55,9 +55,9 @@ impl Filesystem { // on the target instead, so the mode fopen would have left is captured here and put // back below. let target_perms = if shirabe_php_shim::is_file(target_file) { - shirabe_php_shim::fileperms(target_file) + shirabe_php_shim::fileperms(target_file)? } else { - 0o666 & !(shirabe_php_shim::umask() as i64) + 0o666 & !shirabe_php_shim::umask() }; if !shirabe_php_shim::copy(origin_file, target_file) { @@ -85,7 +85,7 @@ impl Filesystem { // Like `cp`, preserve executable permission bits. shirabe_php_shim::chmod( target_file, - (target_perms | (shirabe_php_shim::fileperms(origin_file) & 0o111)) as u32, + (target_perms | (shirabe_php_shim::fileperms(origin_file)? & 0o111)) as u32, ); // Like `cp`, preserve the file modification time. -- cgit v1.3.1-4-g156e