From 239e16881891da1e7cfafab57ac260b3235bc10e Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 17 Sep 2012 22:32:58 -0700 Subject: [PATCH] [FileBackend] Avoid stat call in getFileContents() for swift. * Also removed unused "nostat" flag in addMissingMetadata(). Change-Id: I5f4d827d916b9ca97b9ffd6943c73b6b2faae724 --- includes/filebackend/SwiftFileBackend.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 2cedb62061..abe834ac76 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -784,8 +784,7 @@ class SwiftFileBackend extends FileBackendStore { $status = Status::newGood(); $scopeLockS = $this->getScopedFileLocks( array( $path ), LockManager::LOCK_UW, $status ); if ( $status->isOK() ) { - # Do not stat the file in getLocalCopy() to avoid infinite loops - $tmpFile = $this->getLocalCopy( array( 'src' => $path, 'latest' => 1, 'nostat' => 1 ) ); + $tmpFile = $this->getLocalCopy( array( 'src' => $path, 'latest' => 1 ) ); if ( $tmpFile ) { $hash = $tmpFile->getSha1Base36(); if ( $hash !== false ) { @@ -803,7 +802,7 @@ class SwiftFileBackend extends FileBackendStore { /** * @see FileBackend::getFileContents() - * @return bool|null|string + * @return bool|string */ public function getFileContents( array $params ) { list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); @@ -811,16 +810,13 @@ class SwiftFileBackend extends FileBackendStore { return false; // invalid storage path } - if ( !$this->fileExists( $params ) ) { - return null; - } - $data = false; try { $sContObj = $this->getContainer( $srcCont ); $obj = new CF_Object( $sContObj, $srcRel, false, false ); // skip HEAD $data = $obj->read( $this->headersFromParams( $params ) ); } catch ( NoSuchContainerException $e ) { + } catch ( NoSuchObjectException $e ) { } catch ( CloudFilesException $e ) { // some other exception? $this->handleException( $e, null, __METHOD__, $params ); } @@ -1043,7 +1039,7 @@ class SwiftFileBackend extends FileBackendStore { } // Blindly create a tmp file and stream to it, catching any exception if the file does - // not exist. Also, doing a stat here will cause infinite loops when filling metadata. + // not exist. Also, doing a stat here will cause infinite loops in addMissingMetadata(). $tmpFile = null; try { $sContObj = $this->getContainer( $srcCont ); -- 2.20.1