1
0
Fork 0

Avoid failing hard if the target empty dir cannot be deleted when extracting archives, fixes #9947

pull/9959/head
Jordi Boggiano 2021-06-07 15:34:03 +02:00
parent c4f675fe84
commit e013b479da
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 10 additions and 1 deletions

View File

@ -137,9 +137,18 @@ abstract class ArchiveDownloader extends FileDownloader
};
$renameAsOne = false;
if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectoryPhp($path))) {
if (!file_exists($path)) {
$renameAsOne = true;
}
if ($filesystem->isDirEmpty($path)) {
try {
if ($filesystem->removeDirectoryPhp($path)) {
$renameAsOne = true;
}
} catch (\RuntimeException $e) {
// ignore error, and simply do not renameAsOne
}
}
$contentDir = $getFolderContent($temporaryDir);
$singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));