X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilebackend%2FSwiftFileBackend.php;h=2f4be9ed4a74bca93dd2388299885410ea695143;hb=9a4968a2bab4104a0bff7da5771a271b95df00bf;hp=706da96c46d5d955392d93e1db71da07ef7a2a61;hpb=9b221adb025e5d0add2f4393784482a40596324f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 706da96c46..2f4be9ed4a 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -72,6 +72,9 @@ class SwiftFileBackend extends FileBackendStore { /** @var int UNIX timestamp */ protected $authErrorTimestamp = null; + /** @var bool Whether the server is an Ceph RGW */ + protected $isRGW = false; + /** * @see FileBackendStore::__construct() * Additional $config params include: @@ -1061,11 +1064,14 @@ class SwiftFileBackend extends FileBackendStore { foreach ( $reqs as $path => $op ) { list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $op['response']; fclose( $op['stream'] ); // close open handle - if ( $rcode >= 200 && $rcode <= 299 - // double check that the disk is not full/broken - && $tmpFiles[$path]->getSize() == $rhdrs['content-length'] - ) { - // good + if ( $rcode >= 200 && $rcode <= 299 ) { + // Double check that the disk is not full/broken + if ( $tmpFiles[$path]->getSize() != $rhdrs['content-length'] ) { + $tmpFiles[$path] = null; + $rerr = "Got {$tmpFiles[$path]->getSize()}/{$rhdrs['content-length']} bytes"; + $this->onError( null, __METHOD__, + array( 'src' => $path ) + $ep, $rerr, $rcode, $rdesc ); + } } elseif ( $rcode === 404 ) { $tmpFiles[$path] = false; } else { @@ -1272,7 +1278,7 @@ class SwiftFileBackend extends FileBackendStore { return null; } - wfProfileIn( __METHOD__. "-{$this->name}-miss" ); + wfProfileIn( __METHOD__ . "-{$this->name}-miss" ); list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( array( 'method' => 'HEAD', 'url' => $this->storageUrl( $auth, $container ), @@ -1391,7 +1397,7 @@ class SwiftFileBackend extends FileBackendStore { * * @param string $fullCont * @param string $type ('info' for a list of object detail maps, 'names' for names only) - * @param integer $limit + * @param int $limit * @param string|null $after * @param string|null $prefix * @param string|null $delim @@ -1518,6 +1524,9 @@ class SwiftFileBackend extends FileBackendStore { 'md5' => ctype_xdigit( $rhdrs['etag'] ) ? $rhdrs['etag'] : null, 'xattr' => array( 'metadata' => $metadata, 'headers' => $headers ) ); + if ( $this->isRGW ) { + $stat['latest'] = true; // strong consistency + } } elseif ( $rcode === 404 ) { $stat = false; } else { @@ -1582,6 +1591,10 @@ class SwiftFileBackend extends FileBackendStore { return null; } } + // Ceph RGW does not use in URLs (OpenStack Swift uses "/v1/") + if ( substr( $this->authCreds['storage_url'], -3 ) === '/v1' ) { + $this->isRGW = true; // take advantage of strong consistency + } } return $this->authCreds; @@ -1631,7 +1644,7 @@ class SwiftFileBackend extends FileBackendStore { * @param string $func * @param array $params * @param string $err Error string - * @param integer $code HTTP status + * @param int $code HTTP status * @param string $desc HTTP status description */ public function onError( $status, $func, array $params, $err = '', $code = 0, $desc = '' ) {