mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-30 05:58:12 +02:00
Implement DestructibleInterface on BuildLog
Summary: Depends on D19133. Ref T13088. Allows build logs to be formally destroyed, cleaning up their chunks and file data. Test Plan: - Used `bin/remove destroy` to destroy a log, verified chunks and files were removed. - Used `bin/harbormaster rebuild-log` to force a log to rebuild, verified files were destroyed and regenerated. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13088 Differential Revision: https://secure.phabricator.com/D19134
This commit is contained in:
parent
9b4295ed60
commit
e920e2b143
3 changed files with 54 additions and 16 deletions
|
@ -6511,6 +6511,7 @@ phutil_register_library_map(array(
|
|||
'HarbormasterBuildLog' => array(
|
||||
'HarbormasterDAO',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'HarbormasterBuildLogChunk' => 'HarbormasterDAO',
|
||||
'HarbormasterBuildLogChunkIterator' => 'PhutilBufferedIterator',
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
final class HarbormasterBuildLog
|
||||
extends HarbormasterDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorDestructibleInterface {
|
||||
|
||||
protected $buildTargetPHID;
|
||||
protected $logSource;
|
||||
|
@ -317,7 +319,55 @@ final class HarbormasterBuildLog
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,20 +62,7 @@ final class HarbormasterLogWorker extends HarbormasterWorker {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue