Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/query/DiffusionFileFutureQuery.php
| Show All 36 Lines | abstract class DiffusionFileFutureQuery | ||||
| final public function getExceededByteLimit() { | final public function getExceededByteLimit() { | ||||
| return $this->didHitByteLimit; | return $this->didHitByteLimit; | ||||
| } | } | ||||
| final public function getExceededTimeLimit() { | final public function getExceededTimeLimit() { | ||||
| return $this->didHitTimeLimit; | return $this->didHitTimeLimit; | ||||
| } | } | ||||
| abstract protected function getFileContentFuture(); | abstract protected function newQueryFuture(); | ||||
| final public function respondToConduitRequest(ConduitAPIRequest $request) { | final public function respondToConduitRequest(ConduitAPIRequest $request) { | ||||
| $drequest = $this->getRequest(); | $drequest = $this->getRequest(); | ||||
| $timeout = $request->getValue('timeout'); | $timeout = $request->getValue('timeout'); | ||||
| if ($timeout) { | if ($timeout) { | ||||
| $this->setTimeout($timeout); | $this->setTimeout($timeout); | ||||
| } | } | ||||
| Show All 23 Lines | final public function respondToConduitRequest(ConduitAPIRequest $request) { | ||||
| return array( | return array( | ||||
| 'tooSlow' => $too_slow, | 'tooSlow' => $too_slow, | ||||
| 'tooHuge' => $too_huge, | 'tooHuge' => $too_huge, | ||||
| 'filePHID' => $file_phid, | 'filePHID' => $file_phid, | ||||
| ); | ); | ||||
| } | } | ||||
| final public function executeInline() { | final public function executeInline() { | ||||
| $future = $this->getFileContentFuture(); | $future = $this->newConfiguredQueryFuture(); | ||||
| list($stdout) = $future->resolvex(); | list($stdout) = $future->resolvex(); | ||||
| return $future; | return $stdout; | ||||
| } | } | ||||
| final protected function executeQuery() { | final protected function executeQuery() { | ||||
| $future = $this->newConfiguredFileContentFuture(); | $future = $this->newQueryFuture(); | ||||
| $drequest = $this->getRequest(); | $drequest = $this->getRequest(); | ||||
| $name = basename($drequest->getPath()); | $name = basename($drequest->getPath()); | ||||
| $ttl = PhabricatorTime::getNow() + phutil_units('48 hours in seconds'); | $ttl = PhabricatorTime::getNow() + phutil_units('48 hours in seconds'); | ||||
| try { | try { | ||||
| $threshold = PhabricatorFileStorageEngine::getChunkThreshold(); | $threshold = PhabricatorFileStorageEngine::getChunkThreshold(); | ||||
| Show All 29 Lines | if ($byte_limit && ($file->getByteSize() > $byte_limit)) { | ||||
| unset($unguarded); | unset($unguarded); | ||||
| $file = null; | $file = null; | ||||
| } | } | ||||
| return $file; | return $file; | ||||
| } | } | ||||
| private function newConfiguredFileContentFuture() { | private function newConfiguredQueryFuture() { | ||||
| $future = $this->getFileContentFuture(); | $future = $this->newQueryFuture(); | ||||
| if ($this->getTimeout()) { | if ($this->getTimeout()) { | ||||
| $future->setTimeout($this->getTimeout()); | $future->setTimeout($this->getTimeout()); | ||||
| } | } | ||||
| $byte_limit = $this->getByteLimit(); | $byte_limit = $this->getByteLimit(); | ||||
| if ($byte_limit) { | if ($byte_limit) { | ||||
| $future->setStdoutSizeLimit($byte_limit + 1); | $future->setStdoutSizeLimit($byte_limit + 1); | ||||
| } | } | ||||
| return $future; | return $future; | ||||
| } | } | ||||
| } | } | ||||