Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15335076
D18585.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D18585.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -459,6 +459,7 @@
'DifferentialHostField' => 'applications/differential/customfield/DifferentialHostField.php',
'DifferentialHovercardEngineExtension' => 'applications/differential/engineextension/DifferentialHovercardEngineExtension.php',
'DifferentialHunk' => 'applications/differential/storage/DifferentialHunk.php',
+ 'DifferentialHunkArchiveGarbageCollector' => 'applications/differential/garbagecollector/DifferentialHunkArchiveGarbageCollector.php',
'DifferentialHunkParser' => 'applications/differential/parser/DifferentialHunkParser.php',
'DifferentialHunkParserTestCase' => 'applications/differential/parser/__tests__/DifferentialHunkParserTestCase.php',
'DifferentialHunkQuery' => 'applications/differential/query/DifferentialHunkQuery.php',
@@ -5465,6 +5466,7 @@
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
),
+ 'DifferentialHunkArchiveGarbageCollector' => 'PhabricatorGarbageCollector',
'DifferentialHunkParser' => 'Phobject',
'DifferentialHunkParserTestCase' => 'PhabricatorTestCase',
'DifferentialHunkQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
diff --git a/src/applications/differential/garbagecollector/DifferentialHunkArchiveGarbageCollector.php b/src/applications/differential/garbagecollector/DifferentialHunkArchiveGarbageCollector.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/garbagecollector/DifferentialHunkArchiveGarbageCollector.php
@@ -0,0 +1,31 @@
+<?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);
+ }
+
+}
diff --git a/src/applications/differential/storage/DifferentialModernHunk.php b/src/applications/differential/storage/DifferentialModernHunk.php
--- a/src/applications/differential/storage/DifferentialModernHunk.php
+++ b/src/applications/differential/storage/DifferentialModernHunk.php
@@ -42,6 +42,9 @@
'key_created' => array(
'columns' => array('dateCreated'),
),
+ 'key_archive' => array(
+ 'columns' => array('dataType', 'dateCreated'),
+ ),
),
) + parent::getConfiguration();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 9, 2:06 PM (3 d, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223620
Default Alt Text
D18585.diff (2 KB)
Attached To
Mode
D18585: Automatically archive old Differential hunks into file storage
Attached
Detach File
Event Timeline
Log In to Comment