Avoid cleaning up $path in downloaders if it is the CWD (create-project use case), refs #9396

main
Jordi Boggiano 4 years ago
parent 6cb0aff417
commit 1bf2df19dd
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -60,7 +60,11 @@ abstract class ArchiveDownloader extends FileDownloader
} while (is_dir($temporaryDir));
$this->addCleanupPath($package, $temporaryDir);
$this->addCleanupPath($package, $path);
// avoid cleaning up $path if installing in "." for eg create-project as we can not
// delete the directory we are currently in on windows
if (!is_dir($path) || realpath($path) !== getcwd()) {
$this->addCleanupPath($package, realpath($path));
}
$this->filesystem->ensureDirectoryExists($temporaryDir);
$fileName = $this->getFileName($package, $path);
@ -73,10 +77,12 @@ abstract class ArchiveDownloader extends FileDownloader
$self->clearLastCacheWrite($package);
// clean up
$filesystem->removeDirectory($path);
$filesystem->removeDirectory($temporaryDir);
if (is_dir($path) && realpath($path) !== getcwd()) {
$filesystem->removeDirectory($path);
}
$self->removeCleanupPath($package, $temporaryDir);
$self->removeCleanupPath($package, $path);
$self->removeCleanupPath($package, realpath($path));
};
$promise = null;

@ -293,7 +293,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
}
foreach ($dirsToCleanUp as $dir) {
if (is_dir($dir) && $this->filesystem->isDirEmpty($dir)) {
if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
$this->filesystem->removeDirectory($dir);
}
}

Loading…
Cancel
Save