From ed98a1cc8464192d939e2b4542b9f093f1a92737 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Tue, 19 Aug 2014 12:01:17 -0700 Subject: [PATCH] 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 --- .../plugin/DarkConsoleServicesPlugin.php | 1 + .../engine/PhabricatorS3FileStorageEngine.php | 27 +++++++++++++++++-- .../query/PhabricatorPasteSearchEngine.php | 4 +-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/aphront/console/plugin/DarkConsoleServicesPlugin.php b/src/aphront/console/plugin/DarkConsoleServicesPlugin.php index c085815648..7f33f9ba6d 100644 --- a/src/aphront/console/plugin/DarkConsoleServicesPlugin.php +++ b/src/aphront/console/plugin/DarkConsoleServicesPlugin.php @@ -246,6 +246,7 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin { case 'exec': $info = $row['command']; break; + case 's3': case 'conduit': $info = $row['method']; break; diff --git a/src/applications/files/engine/PhabricatorS3FileStorageEngine.php b/src/applications/files/engine/PhabricatorS3FileStorageEngine.php index 1dc8c7d9cd..d64a381c25 100644 --- a/src/applications/files/engine/PhabricatorS3FileStorageEngine.php +++ b/src/applications/files/engine/PhabricatorS3FileStorageEngine.php @@ -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()); } diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php index 79cf87b9f6..209f519ed9 100644 --- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php +++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php @@ -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)