From 558c22c072d7e7e77e0e5e3493a71727301f7c73 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Jun 2026 13:52:54 +0900 Subject: fix(self-update-command): resolve finder-related phase-b TODOs - Add Display for SplFileInfo (PHP (string) cast -> getPathname) and use it in clean_backups instead of a debug-format placeholder. - Generalize iterator_to_array's signature to preserve the element type so get_last_backup_version collects real SplFileInfo and returns the last basename, instead of mapping every entry to PhpMixed::Null. - Drop the stale builder-restructure TODO in get_old_installation_finder. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/command/self_update_command.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'crates/shirabe/src/command/self_update_command.rs') diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index 63e6a0c..1dc8d87 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -976,8 +976,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ if file.get_basename(Some(Self::OLD_INSTALL_EXT)) == except.unwrap_or_default() { continue; } - // TODO(phase-b): SplFileInfo to string conversion (PHP __toString returns the path) - let file_str = format!("{:?}", file); + let file_str = file.to_string(); io.write_error3( &format!("Removing: {}", file_str), true, @@ -990,21 +989,13 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ pub(crate) fn get_last_backup_version(&self, rollback_dir: &str) -> Option { let mut finder = self.get_old_installation_finder(rollback_dir); finder.sort_by_name(); - // TODO(phase-b): iterator_to_array → Vec; PHP end() returns last value - let files = iterator_to_array(finder.into_iter().map(|_| PhpMixed::Null)); - - if (files.len() as i64) > 0 { - let last_file = files.last().cloned(); - return last_file - // PHP: end($files)->getBasename(self::OLD_INSTALL_EXT) - .and_then(|f| f.as_string().map(|s| s.to_string())); - } - - None + let files = iterator_to_array(finder); + files + .last() + .map(|f| f.get_basename(Some(Self::OLD_INSTALL_EXT))) } pub(crate) fn get_old_installation_finder(&self, rollback_dir: &str) -> Finder { - // TODO(phase-b): builder returns &mut Self; restructure to return owned Finder let mut finder = Finder::create(); finder .depth(0) -- cgit v1.3.1