Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(re-open) Fix directory detection for Windows directory symlinks #125

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Jobs/IncludeFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ protected function exportIncludedDirectory(string $source, string $target, Desti
continue;
}

// Checkin isDir() on $item could lead to false negatives due to the way
// symlinks are handled on Windows, especially if created under Git-For-Windows.
// When debugging it could lead to isDir(), isFile() and isLink() to all 3 be false.
// Despite that, getRealPath() does return the resolved symlink path.
// Hence why we check on $realItem instead.
// Copying Windows "symlinks" as files would also be "wrong" and not portable across file systems.
$realItem = new \SplFileInfo($item->getRealPath());
if ($realItem->isDir()) {
// Since it was a symlink, the subfiles weren't crawled recursively
// so we need to "recursively" export that directory in our export
// destination to maintain the expected file structure, and to copy
// absolutely all the files we needed to copy.
$this->exportIncludedDirectory(
$realItem->getPathname(),
$target.'/'.$iterator->getSubPathName(),
$destination
);
continue;
}

$this->exportIncludedFile(
$item->getPathname(),
$target.'/'.$iterator->getSubPathName(),
Expand Down
Loading