Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15485054
D19134.id45855.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D19134.id45855.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
@@ -6511,6 +6511,7 @@
'HarbormasterBuildLog' => array(
'HarbormasterDAO',
'PhabricatorPolicyInterface',
+ 'PhabricatorDestructibleInterface',
),
'HarbormasterBuildLogChunk' => 'HarbormasterDAO',
'HarbormasterBuildLogChunkIterator' => 'PhutilBufferedIterator',
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
@@ -2,7 +2,9 @@
final class HarbormasterBuildLog
extends HarbormasterDAO
- implements PhabricatorPolicyInterface {
+ implements
+ PhabricatorPolicyInterface,
+ PhabricatorDestructibleInterface {
protected $buildTargetPHID;
protected $logSource;
@@ -317,7 +319,55 @@
public function describeAutomaticCapability($capability) {
return pht(
- "Users must be able to see a build target to view it's build log.");
+ 'Users must be able to see a build target to view its build log.');
+ }
+
+
+/* -( PhabricatorDestructibleInterface )----------------------------------- */
+
+
+ public function destroyObjectPermanently(
+ PhabricatorDestructionEngine $engine) {
+ $this->destroyFile($engine);
+ $this->destroyChunks();
+ $this->delete();
+ }
+
+ public function destroyFile(PhabricatorDestructionEngine $engine = null) {
+ if (!$engine) {
+ $engine = new PhabricatorDestructionEngine();
+ }
+
+ $file_phid = $this->getFilePHID();
+ if ($file_phid) {
+ $viewer = $engine->getViewer();
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($file_phid))
+ ->executeOne();
+ if ($file) {
+ $engine->destroyObject($file);
+ }
+ }
+
+ $this->setFilePHID(null);
+
+ return $this;
+ }
+
+ public function destroyChunks() {
+ $chunk = new HarbormasterBuildLogChunk();
+ $conn = $chunk->establishConnection('w');
+
+ // Just delete the chunks directly so we don't have to pull the data over
+ // the wire for large logs.
+ queryfx(
+ $conn,
+ 'DELETE FROM %T WHERE logID = %d',
+ $chunk->getTableName(),
+ $this->getID());
+
+ return $this;
}
diff --git a/src/applications/harbormaster/worker/HarbormasterLogWorker.php b/src/applications/harbormaster/worker/HarbormasterLogWorker.php
--- a/src/applications/harbormaster/worker/HarbormasterLogWorker.php
+++ b/src/applications/harbormaster/worker/HarbormasterLogWorker.php
@@ -62,20 +62,7 @@
}
if ($is_force) {
- $file_phid = $log->getFilePHID();
- if ($file_phid) {
- $file = id(new PhabricatorFileQuery())
- ->setViewer($viewer)
- ->withPHIDs(array($file_phid))
- ->executeOne();
- if ($file) {
- id(new PhabricatorDestructionEngine())
- ->destroyObject($file);
- }
- $log
- ->setFilePHID(null)
- ->save();
- }
+ $log->destroyFile();
}
if (!$log->getFilePHID()) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 10, 9:31 PM (2 w, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7679475
Default Alt Text
D19134.id45855.diff (3 KB)
Attached To
Mode
D19134: Implement DestructibleInterface on BuildLog
Attached
Detach File
Event Timeline
Log In to Comment