mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Paste - fix caching mechanism for S3-stored files
Summary: Fixes T5798. We basically weren't using the caching mechanism. Also adds service calls for S3 stuff, and support for seeing a little info like you can for conduit. Test Plan: uploaded a paste, looked at paste list - no s3 service calls. edited the paste, looked at paste list - no s3 service calls and edited content properly shown Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5798 Differential Revision: https://secure.phabricator.com/D10294
This commit is contained in:
parent
59b626d2c1
commit
ed98a1cc84
3 changed files with 28 additions and 4 deletions
|
@ -246,6 +246,7 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
|
||||||
case 'exec':
|
case 'exec':
|
||||||
$info = $row['command'];
|
$info = $row['command'];
|
||||||
break;
|
break;
|
||||||
|
case 's3':
|
||||||
case 'conduit':
|
case 'conduit':
|
||||||
$info = $row['method'];
|
$info = $row['method'];
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -40,11 +40,18 @@ final class PhabricatorS3FileStorageEngine
|
||||||
$name = 'phabricator/'.implode('/', $parts);
|
$name = 'phabricator/'.implode('/', $parts);
|
||||||
|
|
||||||
AphrontWriteGuard::willWrite();
|
AphrontWriteGuard::willWrite();
|
||||||
|
$profiler = PhutilServiceProfiler::getInstance();
|
||||||
|
$call_id = $profiler->beginServiceCall(
|
||||||
|
array(
|
||||||
|
'type' => 's3',
|
||||||
|
'method' => 'putObject',
|
||||||
|
));
|
||||||
$s3->putObject(
|
$s3->putObject(
|
||||||
$data,
|
$data,
|
||||||
$this->getBucketName(),
|
$this->getBucketName(),
|
||||||
$name,
|
$name,
|
||||||
$acl = 'private');
|
$acl = 'private');
|
||||||
|
$profiler->endServiceCall($call_id, array());
|
||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
@ -54,9 +61,17 @@ final class PhabricatorS3FileStorageEngine
|
||||||
* Load a stored blob from Amazon S3.
|
* Load a stored blob from Amazon S3.
|
||||||
*/
|
*/
|
||||||
public function readFile($handle) {
|
public function readFile($handle) {
|
||||||
$result = $this->newS3API()->getObject(
|
$s3 = $this->newS3API();
|
||||||
|
$profiler = PhutilServiceProfiler::getInstance();
|
||||||
|
$call_id = $profiler->beginServiceCall(
|
||||||
|
array(
|
||||||
|
'type' => 's3',
|
||||||
|
'method' => 'getObject',
|
||||||
|
));
|
||||||
|
$result = $s3->getObject(
|
||||||
$this->getBucketName(),
|
$this->getBucketName(),
|
||||||
$handle);
|
$handle);
|
||||||
|
$profiler->endServiceCall($call_id, array());
|
||||||
|
|
||||||
// NOTE: The implementation of the API that we're using may respond with
|
// NOTE: The implementation of the API that we're using may respond with
|
||||||
// a successful result that has length 0 and no body property.
|
// a successful result that has length 0 and no body property.
|
||||||
|
@ -73,9 +88,17 @@ final class PhabricatorS3FileStorageEngine
|
||||||
*/
|
*/
|
||||||
public function deleteFile($handle) {
|
public function deleteFile($handle) {
|
||||||
AphrontWriteGuard::willWrite();
|
AphrontWriteGuard::willWrite();
|
||||||
$this->newS3API()->deleteObject(
|
$s3 = $this->newS3API();
|
||||||
|
$profiler = PhutilServiceProfiler::getInstance();
|
||||||
|
$call_id = $profiler->beginServiceCall(
|
||||||
|
array(
|
||||||
|
'type' => 's3',
|
||||||
|
'method' => 'deleteObject',
|
||||||
|
));
|
||||||
|
$s3->deleteObject(
|
||||||
$this->getBucketName(),
|
$this->getBucketName(),
|
||||||
$handle);
|
$handle);
|
||||||
|
$profiler->endServiceCall($call_id, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class PhabricatorPasteSearchEngine
|
||||||
|
|
||||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
||||||
$query = id(new PhabricatorPasteQuery())
|
$query = id(new PhabricatorPasteQuery())
|
||||||
->needRawContent(true)
|
->needContent(true)
|
||||||
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()))
|
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()))
|
||||||
->withLanguages($saved->getParameter('languages', array()));
|
->withLanguages($saved->getParameter('languages', array()));
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ final class PhabricatorPasteSearchEngine
|
||||||
$created = phabricator_date($paste->getDateCreated(), $viewer);
|
$created = phabricator_date($paste->getDateCreated(), $viewer);
|
||||||
$author = $handles[$paste->getAuthorPHID()]->renderLink();
|
$author = $handles[$paste->getAuthorPHID()]->renderLink();
|
||||||
|
|
||||||
$lines = phutil_split_lines($paste->getRawContent());
|
$lines = phutil_split_lines($paste->getContent());
|
||||||
|
|
||||||
$preview = id(new PhabricatorSourceCodeView())
|
$preview = id(new PhabricatorSourceCodeView())
|
||||||
->setLimit(5)
|
->setLimit(5)
|
||||||
|
|
Loading…
Reference in a new issue