Differential D18585 Diff 44629 src/applications/differential/garbagecollector/DifferentialHunkArchiveGarbageCollector.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/garbagecollector/DifferentialHunkArchiveGarbageCollector.php
- This file was added.
<?php | |||||
final class DifferentialHunkArchiveGarbageCollector | |||||
extends PhabricatorGarbageCollector { | |||||
const COLLECTORCONST = 'differential.hunk'; | |||||
public function getCollectorName() { | |||||
return pht('Differential Hunk Archiver'); | |||||
} | |||||
public function getDefaultRetentionPolicy() { | |||||
return phutil_units('30 days in seconds'); | |||||
} | |||||
protected function collectGarbage() { | |||||
$table = new DifferentialModernHunk(); | |||||
$hunks = $table->loadAllWhere( | |||||
'dataType = %s AND dateCreated < %d LIMIT 10', | |||||
DifferentialModernHunk::DATATYPE_TEXT, | |||||
$this->getGarbageEpoch()); | |||||
foreach ($hunks as $hunk) { | |||||
$hunk->saveAsFile(); | |||||
} | |||||
return (count($hunks) == 10); | |||||
} | |||||
} |