Differential D14219 Diff 34352 src/applications/files/garbagecollector/PhabricatorFileTemporaryGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/garbagecollector/PhabricatorFileTemporaryGarbageCollector.php
| <?php | <?php | ||||
| final class PhabricatorFileTemporaryGarbageCollector | final class PhabricatorFileTemporaryGarbageCollector | ||||
| extends PhabricatorGarbageCollector { | extends PhabricatorGarbageCollector { | ||||
| const COLLECTORCONST = 'files.ttl'; | const COLLECTORCONST = 'files.ttl'; | ||||
| public function getCollectorName() { | public function getCollectorName() { | ||||
| return pht('Files (TTL)'); | return pht('Files (TTL)'); | ||||
| } | } | ||||
| public function hasAutomaticPolicy() { | public function hasAutomaticPolicy() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function collectGarbage() { | protected function collectGarbage() { | ||||
| $files = id(new PhabricatorFile())->loadAllWhere( | $files = id(new PhabricatorFile())->loadAllWhere( | ||||
| 'ttl < %d LIMIT 100', | 'ttl < %d LIMIT 100', | ||||
| time()); | PhabricatorTime::getNow()); | ||||
| foreach ($files as $file) { | foreach ($files as $file) { | ||||
| $file->delete(); | $file->delete(); | ||||
| } | } | ||||
| return (count($files) == 100); | return (count($files) == 100); | ||||
| } | } | ||||
| } | } | ||||