1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 05:20:56 +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:
Bob Trahan 2014-08-19 12:01:17 -07:00
parent 59b626d2c1
commit ed98a1cc84
3 changed files with 28 additions and 4 deletions

View file

@ -246,6 +246,7 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
case 'exec':
$info = $row['command'];
break;
case 's3':
case 'conduit':
$info = $row['method'];
break;

View file

@ -40,11 +40,18 @@ final class PhabricatorS3FileStorageEngine
$name = 'phabricator/'.implode('/', $parts);
AphrontWriteGuard::willWrite();
$profiler = PhutilServiceProfiler::getInstance();
$call_id = $profiler->beginServiceCall(
array(
'type' => 's3',
'method' => 'putObject',
));
$s3->putObject(
$data,
$this->getBucketName(),
$name,
$acl = 'private');
$profiler->endServiceCall($call_id, array());
return $name;
}
@ -54,9 +61,17 @@ final class PhabricatorS3FileStorageEngine
* Load a stored blob from Amazon S3.
*/
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(),
$handle);
$profiler->endServiceCall($call_id, array());
// NOTE: The implementation of the API that we're using may respond with
// a successful result that has length 0 and no body property.
@ -73,9 +88,17 @@ final class PhabricatorS3FileStorageEngine
*/
public function deleteFile($handle) {
AphrontWriteGuard::willWrite();
$this->newS3API()->deleteObject(
$s3 = $this->newS3API();
$profiler = PhutilServiceProfiler::getInstance();
$call_id = $profiler->beginServiceCall(
array(
'type' => 's3',
'method' => 'deleteObject',
));
$s3->deleteObject(
$this->getBucketName(),
$handle);
$profiler->endServiceCall($call_id, array());
}

View file

@ -27,7 +27,7 @@ final class PhabricatorPasteSearchEngine
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhabricatorPasteQuery())
->needRawContent(true)
->needContent(true)
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()))
->withLanguages($saved->getParameter('languages', array()));
@ -149,7 +149,7 @@ final class PhabricatorPasteSearchEngine
$created = phabricator_date($paste->getDateCreated(), $viewer);
$author = $handles[$paste->getAuthorPHID()]->renderLink();
$lines = phutil_split_lines($paste->getRawContent());
$lines = phutil_split_lines($paste->getContent());
$preview = id(new PhabricatorSourceCodeView())
->setLimit(5)