From 828d396110ebd82e4a45499257256607bfc4bf0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 20 Mar 2015 19:01:06 +0100 Subject: [PATCH] Clean up temporary folder in DailyCleanUpCronjob --- .../cronjob/DailyCleanUpCronjob.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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); + } + } + })); } } -- 2.20.1