[FileBackend] Improved getLocalCopy() performance for Swift.
authorAaron <aschulz@wikimedia.org>
Thu, 30 Aug 2012 19:17:28 +0000 (12:17 -0700)
committerAaron <aschulz@wikimedia.org>
Thu, 30 Aug 2012 19:17:28 +0000 (12:17 -0700)
* This eliminates HEAD requests to speed up concatenate() operations (by ~9 seconds for 300 chunks for wmf).

Change-Id: I43456bd59eeb7943e66cae9c1e42dc410c2a8daf

includes/filebackend/SwiftFileBackend.php

index 6f078e8..9081e82 100644 (file)
@@ -989,11 +989,8 @@ class SwiftFileBackend extends FileBackendStore {
                        return null;
                }
 
-               # Check the recursion guard to avoid loops when filling metadata
-               if ( empty( $params['nostat'] ) && !$this->fileExists( $params ) ) {
-                       return null;
-               }
-
+               // 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.
                $tmpFile = null;
                try {
                        $sContObj = $this->getContainer( $srcCont );
@@ -1013,6 +1010,8 @@ class SwiftFileBackend extends FileBackendStore {
                        }
                } catch ( NoSuchContainerException $e ) {
                        $tmpFile = null;
+               } catch ( NoSuchObjectException $e ) {
+                       $tmpFile = null;
                } catch ( CloudFilesException $e ) { // some other exception?
                        $tmpFile = null;
                        $this->handleException( $e, null, __METHOD__, $params );