From 51c4f697f9943d069865864b29d776a5c1afd094 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Tue, 28 Jan 2014 20:17:03 -0800 Subject: [PATCH] Delete artifacts when restarting build Summary: Fixes T4336. This updates the build engine to delete all artifacts when targets are being deleted. This prevents conflicts when builds are restarted. Test Plan: Restarted a build that had a lease host step and it didn't crash. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4336 Differential Revision: https://secure.phabricator.com/D8092 --- .../engine/HarbormasterBuildEngine.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/applications/harbormaster/engine/HarbormasterBuildEngine.php b/src/applications/harbormaster/engine/HarbormasterBuildEngine.php index fc0ae9bcdc..af2057b990 100644 --- a/src/applications/harbormaster/engine/HarbormasterBuildEngine.php +++ b/src/applications/harbormaster/engine/HarbormasterBuildEngine.php @@ -101,6 +101,22 @@ final class HarbormasterBuildEngine extends Phobject { ->setViewer($this->getViewer()) ->withBuildPHIDs(array($build->getPHID())) ->execute(); + + if (!$targets) { + return; + } + + $target_phids = mpull($targets, 'getPHID'); + + $artifacts = id(new HarbormasterBuildArtifactQuery()) + ->setViewer($this->getViewer()) + ->withBuildTargetPHIDs($target_phids) + ->execute(); + + foreach ($artifacts as $artifact) { + $artifact->delete(); + } + foreach ($targets as $target) { $target->delete(); }