1
0
Fork 0

Fix edge case where one adds a target-dir on a package that didnt have one before, refs #2279

pull/2292/head
Jordi Boggiano 2013-09-25 21:07:55 +02:00
parent a813867065
commit 807600b255
2 changed files with 10 additions and 2 deletions

View File

@ -161,7 +161,15 @@ class LibraryInstaller implements InstallerInterface
$initialDownloadPath = $this->getInstallPath($initial);
$targetDownloadPath = $this->getInstallPath($target);
if ($targetDownloadPath !== $initialDownloadPath) {
$this->filesystem->copyThenRemove($initialDownloadPath, $targetDownloadPath);
// if the target is part of the initial dir, 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) {
$this->removeCode($initial);
$this->installCode($target);
return;
}
$this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
}
$this->downloadManager->update($initial, $target, $targetDownloadPath);
}

View File

@ -135,7 +135,7 @@ class LibraryInstallerTest extends TestCase
->getMock();
$filesystem
->expects($this->once())
->method('copyThenRemove')
->method('rename')
->with($this->vendorDir.'/package1', $this->vendorDir.'/package1/newtarget');
$initial = $this->createPackageMock();