Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / harbormaster / controller / HarbormasterBuildLogDownloadController.php
blobee02b256365786fd7763a14f8b5e6347ebe2e84a
1 <?php
3 final class HarbormasterBuildLogDownloadController
4 extends HarbormasterController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $request = $this->getRequest();
12 $viewer = $request->getUser();
14 $id = $request->getURIData('id');
16 $log = id(new HarbormasterBuildLogQuery())
17 ->setViewer($viewer)
18 ->withIDs(array($id))
19 ->executeOne();
20 if (!$log) {
21 return new Aphront404Response();
24 $cancel_uri = $log->getURI();
25 $file_phid = $log->getFilePHID();
27 if (!$file_phid) {
28 return $this->newDialog()
29 ->setTitle(pht('Log Not Finalized'))
30 ->appendParagraph(
31 pht(
32 'Logs must be fully written and processed before they can be '.
33 'downloaded. This log is still being written or processed.'))
34 ->addCancelButton($cancel_uri, pht('Wait Patiently'));
37 $file = id(new PhabricatorFileQuery())
38 ->setViewer($viewer)
39 ->withPHIDs(array($file_phid))
40 ->executeOne();
41 if (!$file) {
42 return $this->newDialog()
43 ->setTitle(pht('Unable to Load File'))
44 ->appendParagraph(
45 pht(
46 'Unable to load the file for this log. The file may have been '.
47 'destroyed.'))
48 ->addCancelButton($cancel_uri);
51 return $file->newDownloadResponse();