1
0
Fork 0

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

pull/9397/head
Jordi Boggiano 2020-11-02 13:50:35 +01:00
parent 6cb0aff417
commit 1bf2df19dd
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 10 additions and 4 deletions

View File

@ -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;

View File

@ -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);
}
}