@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 54 lines 1.4 kB view raw
1<?php 2 3final class HarbormasterBuildLogDownloadController 4 extends HarbormasterController { 5 6 public function shouldAllowPublic() { 7 return true; 8 } 9 10 public function handleRequest(AphrontRequest $request) { 11 $request = $this->getRequest(); 12 $viewer = $request->getUser(); 13 14 $id = $request->getURIData('id'); 15 16 $log = id(new HarbormasterBuildLogQuery()) 17 ->setViewer($viewer) 18 ->withIDs(array($id)) 19 ->executeOne(); 20 if (!$log) { 21 return new Aphront404Response(); 22 } 23 24 $cancel_uri = $log->getURI(); 25 $file_phid = $log->getFilePHID(); 26 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')); 35 } 36 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); 49 } 50 51 return $file->newDownloadResponse(); 52 } 53 54}