1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Implement DestructibleInterface on GitLFS refs

Summary: Ref T7789. Make sure these get cleaned up when a repository is destroyed.

Test Plan:
  - Created a new repository.
  - Pushed some LFS data to it.
  - Used `bin/remove destroy` to nuke it.
  - Verified the LFS stuff was cleaned up and the underlying files were destroyed (`SELECT * FROM repository_gitlfsref`, etc).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7789

Differential Revision: https://secure.phabricator.com/D15493
This commit is contained in:
epriestley 2016-03-18 07:16:24 -07:00
parent a24f001b08
commit 78e36d6b17
3 changed files with 31 additions and 1 deletions

View file

@ -7672,6 +7672,7 @@ phutil_register_library_map(array(
'PhabricatorRepositoryGitLFSRef' => array(
'PhabricatorRepositoryDAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
),
'PhabricatorRepositoryGitLFSRefQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorRepositoryGraphCache' => 'Phobject',

View file

@ -2435,6 +2435,14 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
$engine->destroyObject($atom);
}
$lfs_refs = id(new PhabricatorRepositoryGitLFSRefQuery())
->setViewer($engine->getViewer())
->withRepositoryPHIDs(array($phid))
->execute();
foreach ($lfs_refs as $ref) {
$engine->destroyObject($ref);
}
$this->saveTransaction();
}

View file

@ -2,7 +2,9 @@
final class PhabricatorRepositoryGitLFSRef
extends PhabricatorRepositoryDAO
implements PhabricatorPolicyInterface {
implements
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
protected $repositoryPHID;
protected $objectHash;
@ -48,4 +50,23 @@ final class PhabricatorRepositoryGitLFSRef
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$file_phid = $this->getFilePHID();
$file = id(new PhabricatorFileQuery())
->setViewer($engine->getViewer())
->withPHIDs(array($file_phid))
->executeOne();
if ($file) {
$engine->destroyObject($file);
}
$this->delete();
}
}