From: Tim Düsterhus Date: Sun, 28 Aug 2011 15:03:37 +0000 (+0200) Subject: Fixed cleaning up after installation X-Git-Tag: 2.0.0_Beta_1~1802^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=364a2e49de8a13606bf295280f7a77ac569947ea;p=GitHub%2FWoltLab%2FWCF.git Fixed cleaning up after installation --- diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index 50cc72ec2e..8da8164379 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -16,6 +16,7 @@ use wcf\system\session\SessionHandler; use wcf\system\setup\Installer; use wcf\system\template\SetupTemplateEngine; use wcf\system\WCF; +use wcf\util\DirectoryUtil; use wcf\util\FileUtil; use wcf\util\StringUtil; use wcf\util\UserUtil; @@ -1068,16 +1069,8 @@ class WCFSetup extends WCF { WCF::getTPL()->display('stepInstallPackages'); // delete tmp files - $directory = TMP_DIR.TMP_FILE_PREFIX.'/'; - $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)); - while ($it->valid()) { - // delete all files except directories and packages (required for post-wcfsetup installation) - if (!$it->isDot() && !$it->isDir() && !preg_match('~\.tar(\.gz)?$~', $it->getSubPathName())) { - @unlink($it->key()); - } - - $it->next(); - } + $directory = TMP_DIR.'/'; + DirectoryUtil::getInstance($directory)->removePattern('~\.tar(\.gz)?$~', true); } /** diff --git a/wcfsetup/install/files/lib/util/DirectoryUtil.class.php b/wcfsetup/install/files/lib/util/DirectoryUtil.class.php index bcda8809ec..6bc10f1cd7 100644 --- a/wcfsetup/install/files/lib/util/DirectoryUtil.class.php +++ b/wcfsetup/install/files/lib/util/DirectoryUtil.class.php @@ -282,12 +282,13 @@ class DirectoryUtil { /** * Removes all files that match the given pattern. * - * @param string $pattern pattern to match + * @param string $pattern pattern to match + * @param boolean $negativeMatch should the pattern be inversed */ - public function removePattern($pattern) { + public function removePattern($pattern, $negativeMatch = false) { if (!$this->recursive) throw new SystemException('Removing of files only works in recursive mode'); - $files = $this->getFileObjects(self::SORT_NONE, $pattern); + $files = $this->getFileObjects(self::SORT_NONE, $pattern, $negativeMatch); foreach ($files as $filename => $obj) { if (!is_writable($obj->getPath())) { @@ -295,7 +296,7 @@ class DirectoryUtil { } if ($obj->isDir()) { - rmdir($filename); + @rmdir($filename); } else if ($obj->isFile()) { unlink($filename);