[FileBackend] Avoid stat call in getFileContents() for swift.
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 18 Sep 2012 05:32:58 +0000 (22:32 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 18 Sep 2012 05:32:58 +0000 (22:32 -0700)
* Also removed unused "nostat" flag in addMissingMetadata().

Change-Id: I5f4d827d916b9ca97b9ffd6943c73b6b2faae724

includes/filebackend/SwiftFileBackend.php

index 2cedb62..abe834a 100644 (file)
@@ -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 );