diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-09 18:41:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-09 18:41:49 +0900 |
| commit | 6d257691a39fb8c4191f4564ec6406d080dbf6b5 (patch) | |
| tree | 0e3749b2a35bb2a3afc0d72575024194417b2257 /crates/shirabe-symfony-filesystem/src/filesystem.rs | |
| parent | 72cbecaec29cecc723ce29c87d10048114aeef5b (diff) | |
| download | php-shirabe-6d257691a39fb8c4191f4564ec6406d080dbf6b5.tar.gz php-shirabe-6d257691a39fb8c4191f4564ec6406d080dbf6b5.tar.zst php-shirabe-6d257691a39fb8c4191f4564ec6406d080dbf6b5.zip | |
feat(path-downloader): restrict a mirrored path package to its archivable files
PathDownloader builds an ArchivableFilesFinder and hands it to
Filesystem::mirror as the iterator that selects what to copy, so a path
package installed by mirroring drops what .gitattributes marks
export-ignore, what .gitignore excludes and the VCS directories. The
port dropped the argument, and mirrored the source tree whole.
Every method mirror() calls on the entries it walks is derived from the
pathname, so the iterator is modeled as a list of pathnames rather than
as a Traversable of SplFileInfo.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-symfony-filesystem/src/filesystem.rs')
| -rw-r--r-- | crates/shirabe-symfony-filesystem/src/filesystem.rs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/crates/shirabe-symfony-filesystem/src/filesystem.rs b/crates/shirabe-symfony-filesystem/src/filesystem.rs index 5d2fb1d2..737c3bea 100644 --- a/crates/shirabe-symfony-filesystem/src/filesystem.rs +++ b/crates/shirabe-symfony-filesystem/src/filesystem.rs @@ -280,7 +280,12 @@ impl Filesystem { Ok(()) } - pub fn mirror(&self, origin_dir: &str, target_dir: &str) -> anyhow::Result<()> { + pub fn mirror( + &self, + origin_dir: &str, + target_dir: &str, + iterator: Vec<String>, + ) -> anyhow::Result<()> { let target_dir = shirabe_php_shim::rtrim(target_dir, Some("/\\")); let origin_dir = shirabe_php_shim::rtrim(origin_dir, Some("/\\")); let origin_dir_len = origin_dir.len(); @@ -298,21 +303,12 @@ impl Filesystem { .into()); } - let iterator = shirabe_php_shim::recursive_iterator_iterator( - shirabe_php_shim::recursive_directory_iterator( - &origin_dir, - shirabe_php_shim::SKIP_DOTS, - )?, - shirabe_php_shim::RecursiveIteratorIterator::SELF_FIRST, - ); - self.mkdir(&target_dir, 0o777)?; let mut files_created_while_mirroring: indexmap::IndexMap<String, bool> = indexmap::IndexMap::new(); - for file in &iterator { - let pathname = file.get_pathname(); + for pathname in iterator { // SplFileInfo::getRealPath(), which returns false for a path that cannot be resolved. let real_path = shirabe_php_shim::realpath(&pathname); if pathname == target_dir @@ -327,12 +323,15 @@ impl Filesystem { let target = format!("{}{}", target_dir, &pathname[origin_dir_len..]); files_created_while_mirroring.insert(target.clone(), true); - if file.is_link() { + if shirabe_php_shim::is_link(&pathname) { // PHP coerces the false getLinkTarget() returns on failure to the empty string. - self.symlink(&file.get_link_target().unwrap_or_default(), &target)?; - } else if file.is_dir() { + self.symlink( + &shirabe_php_shim::readlink(&pathname).unwrap_or_default(), + &target, + )?; + } else if shirabe_php_shim::is_dir(&pathname) { self.mkdir(&target, 0o777)?; - } else if file.is_file() { + } else if shirabe_php_shim::is_file(&pathname) { self.copy(&pathname, &target)?; } else { return Err(IOException::new( |
