Fix target-dir update checks, fixes #2395
parent
d3ff302194
commit
8398c9f2ab
|
@ -160,9 +160,11 @@ class LibraryInstaller implements InstallerInterface
|
|||
$initialDownloadPath = $this->getInstallPath($initial);
|
||||
$targetDownloadPath = $this->getInstallPath($target);
|
||||
if ($targetDownloadPath !== $initialDownloadPath) {
|
||||
// if the target is part of the initial dir, we force a remove + install
|
||||
// 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) {
|
||||
if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath
|
||||
|| substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath
|
||||
) {
|
||||
$this->removeCode($initial);
|
||||
$this->installCode($target);
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ class LibraryInstallerTest extends TestCase
|
|||
$filesystem
|
||||
->expects($this->once())
|
||||
->method('rename')
|
||||
->with($this->vendorDir.'/package1', $this->vendorDir.'/package1/newtarget');
|
||||
->with($this->vendorDir.'/package1/oldtarget', $this->vendorDir.'/package1/newtarget');
|
||||
|
||||
$initial = $this->createPackageMock();
|
||||
$target = $this->createPackageMock();
|
||||
|
@ -146,6 +146,11 @@ class LibraryInstallerTest extends TestCase
|
|||
->method('getPrettyName')
|
||||
->will($this->returnValue('package1'));
|
||||
|
||||
$initial
|
||||
->expects($this->once())
|
||||
->method('getTargetDir')
|
||||
->will($this->returnValue('oldtarget'));
|
||||
|
||||
$target
|
||||
->expects($this->once())
|
||||
->method('getPrettyName')
|
||||
|
|
Loading…
Reference in New Issue