From: Tim Düsterhus Date: Fri, 20 Mar 2015 18:01:06 +0000 (+0100) Subject: Clean up temporary folder in DailyCleanUpCronjob X-Git-Tag: 2.1.2~23^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=828d396110ebd82e4a45499257256607bfc4bf0b;p=GitHub%2FWoltLab%2FWCF.git Clean up temporary folder in DailyCleanUpCronjob --- diff --git a/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php index d415c3da8a..2778be1ac7 100644 --- a/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php @@ -3,7 +3,10 @@ namespace wcf\system\cronjob; use wcf\data\cronjob\Cronjob; use wcf\data\object\type\ObjectTypeCache; use wcf\system\visitTracker\VisitTracker; +use wcf\system\Callback; use wcf\system\WCF; +use wcf\util\DirectoryUtil; +use wcf\util\FileUtil; /** * Cronjob for a daily system cleanup. @@ -162,5 +165,21 @@ class DailyCleanUpCronjob extends AbstractCronjob { } } } + + // clean up temporary folder + $tempFolder = FileUtil::getTempFolder(); + DirectoryUtil::getInstance($tempFolder)->executeCallback(new Callback(function($filename, $object) use ($tempFolder) { + if ($filename === $tempFolder) return; + if ($filename === $tempFolder.'.htaccess') return; + + if ($object->getMTime() < TIME_NOW - 86400) { + if ($object->isDir()) { + @rmdir($filename); + } + else if ($object->isFile()) { + @unlink($filename); + } + } + })); } }