function LibraryInstaller::updateCode
@phpstan-return PromiseInterface<void|null>|null
Return value
PromiseInterface|null
1 call to LibraryInstaller::updateCode()
- LibraryInstaller::update in vendor/
composer/ composer/ src/ Composer/ Installer/ LibraryInstaller.php - @inheritDoc
File
-
vendor/
composer/ composer/ src/ Composer/ Installer/ LibraryInstaller.php, line 288
Class
- LibraryInstaller
- Package installation manager.
Namespace
Composer\InstallerCode
protected function updateCode(PackageInterface $initial, PackageInterface $target) {
$initialDownloadPath = $this->getInstallPath($initial);
$targetDownloadPath = $this->getInstallPath($target);
if ($targetDownloadPath !== $initialDownloadPath) {
// if the target and initial dirs intersect, we force a remove + install
// to avoid the rename wiping the target dir as part of the initial dir cleanup
if (strpos($initialDownloadPath, $targetDownloadPath) === 0 || strpos($targetDownloadPath, $initialDownloadPath) === 0) {
$promise = $this->removeCode($initial);
if (!$promise instanceof PromiseInterface) {
$promise = \React\Promise\resolve(null);
}
return $promise->then(function () use ($target) : PromiseInterface {
$promise = $this->installCode($target);
if ($promise instanceof PromiseInterface) {
return $promise;
}
return \React\Promise\resolve(null);
});
}
$this->filesystem
->rename($initialDownloadPath, $targetDownloadPath);
}
return $this->getDownloadManager()
->update($initial, $target, $targetDownloadPath);
}