"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Composer/Util/Filesystem.php" between
composer-2.1.2.tar.gz and composer-2.1.3.tar.gz

About: Composer helps you declare, manage, and install dependencies of PHP projects.

Filesystem.php  (composer-2.1.2):Filesystem.php  (composer-2.1.3)
skipping to change at line 169 skipping to change at line 169
return \React\Promise\resolve($self->removeDirectoryPhp($directory)) ; return \React\Promise\resolve($self->removeDirectoryPhp($directory)) ;
}); });
} }
/** /**
* @param string $directory * @param string $directory
* *
* @return bool|null Returns null, when no edge case was hit. Otherwise a bo ol whether removal was successfull * @return bool|null Returns null, when no edge case was hit. Otherwise a bo ol whether removal was successfull
*/ */
private function removeEdgeCases($directory) private function removeEdgeCases($directory, $fallbackToPhp = true)
{ {
if ($this->isSymlinkedDirectory($directory)) { if ($this->isSymlinkedDirectory($directory)) {
return $this->unlinkSymlinkedDirectory($directory); return $this->unlinkSymlinkedDirectory($directory);
} }
if ($this->isJunction($directory)) { if ($this->isJunction($directory)) {
return $this->removeJunction($directory); return $this->removeJunction($directory);
} }
if (is_link($directory)) { if (is_link($directory)) {
skipping to change at line 191 skipping to change at line 191
} }
if (!is_dir($directory) || !file_exists($directory)) { if (!is_dir($directory) || !file_exists($directory)) {
return true; return true;
} }
if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) { if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
throw new \RuntimeException('Aborting an attempted deletion of '.$di rectory.', this was probably not intended, if it is a real use case please repor t it.'); throw new \RuntimeException('Aborting an attempted deletion of '.$di rectory.', this was probably not intended, if it is a real use case please repor t it.');
} }
if (!\function_exists('proc_open')) { if (!\function_exists('proc_open') && $fallbackToPhp) {
return $this->removeDirectoryPhp($directory); return $this->removeDirectoryPhp($directory);
} }
return null; return null;
} }
/** /**
* Recursively delete directory using PHP iterators. * Recursively delete directory using PHP iterators.
* *
* Uses a CHILD_FIRST RecursiveIteratorIterator to sort files * Uses a CHILD_FIRST RecursiveIteratorIterator to sort files
* before directories, creating a single non-recursive loop * before directories, creating a single non-recursive loop
* to delete files/directories in the correct order. * to delete files/directories in the correct order.
* *
* @param string $directory * @param string $directory
* @return bool * @return bool
*/ */
public function removeDirectoryPhp($directory) public function removeDirectoryPhp($directory)
{ {
$edgeCaseResult = $this->removeEdgeCases($directory, false);
if ($edgeCaseResult !== null) {
return $edgeCaseResult;
}
try { try {
$it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryI terator::SKIP_DOTS); $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryI terator::SKIP_DOTS);
} catch (\UnexpectedValueException $e) { } catch (\UnexpectedValueException $e) {
// re-try once after clearing the stat cache if it failed as it // re-try once after clearing the stat cache if it failed as it
// sometimes fails without apparent reason, see https://github.com/c omposer/composer/issues/4009 // sometimes fails without apparent reason, see https://github.com/c omposer/composer/issues/4009
clearstatcache(); clearstatcache();
usleep(100000); usleep(100000);
if (!is_dir($directory)) { if (!is_dir($directory)) {
return true; return true;
} }
skipping to change at line 233 skipping to change at line 238
foreach ($ri as $file) { foreach ($ri as $file) {
if ($file->isDir()) { if ($file->isDir()) {
$this->rmdir($file->getPathname()); $this->rmdir($file->getPathname());
} else { } else {
$this->unlink($file->getPathname()); $this->unlink($file->getPathname());
} }
} }
// release locks on the directory, see https://github.com/composer/compo ser/issues/9945 // release locks on the directory, see https://github.com/composer/compo ser/issues/9945
unset($ri, $it); unset($ri, $it, $file);
return $this->rmdir($directory); return $this->rmdir($directory);
} }
public function ensureDirectoryExists($directory) public function ensureDirectoryExists($directory)
{ {
if (!is_dir($directory)) { if (!is_dir($directory)) {
if (file_exists($directory)) { if (file_exists($directory)) {
throw new \RuntimeException( throw new \RuntimeException(
$directory.' exists and is not a directory.' $directory.' exists and is not a directory.'
 End of changes. 4 change blocks. 
3 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)