diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2013-09-30 00:12:10 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2014-01-08 13:22:11 -0800 |
commit | ac14c1c8a65d154f7a9bc47d1b51f6db67188f86 (patch) | |
tree | d581f21014ede6fcd8b53a0a9489adef76b5cabf /includes/filebackend/SwiftFileBackend.php | |
parent | b8ef0a54700fca3fb6d119cedb657c28df926906 (diff) | |
download | mediawikicore-ac14c1c8a65d154f7a9bc47d1b51f6db67188f86.tar.gz mediawikicore-ac14c1c8a65d154f7a9bc47d1b51f6db67188f86.zip |
filebackend: Added supported for retrieving file metadata/headers
* This can be useful for carrying over metadata when copying files around
* Also fixed a bug in sanitizeHdrs() for Swift (broken content-disposition)
Change-Id: I4534e9acac2b306086797b3677f85c05b98e39fc
Diffstat (limited to 'includes/filebackend/SwiftFileBackend.php')
-rw-r--r-- | includes/filebackend/SwiftFileBackend.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 528889b69bf6..037b1c3c3043 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -142,6 +142,10 @@ class SwiftFileBackend extends FileBackendStore { $this->srvCache = $this->srvCache ?: new EmptyBagOStuff(); } + public function getFeatures() { + return ( FileBackend::ATTR_HEADERS | FileBackend::ATTR_METADATA ); + } + protected function resolveContainerPath( $container, $relStoragePath ) { if ( !mb_check_encoding( $relStoragePath, 'UTF-8' ) ) { // mb_string required by CF return null; // not UTF-8, makes it hard to use CF and the swift HTTP API @@ -179,6 +183,8 @@ class SwiftFileBackend extends FileBackendStore { continue; // blacklisted } elseif ( preg_match( '/^(x-)?content-/', $name ) ) { $headers[$name] = $value; // allowed + } elseif ( preg_match( '/^content-(disposition)/', $name ) ) { + $headers[$name] = $value; // allowed } } } @@ -189,7 +195,7 @@ class SwiftFileBackend extends FileBackendStore { $part = trim( $part ); $new = ( $disposition === '' ) ? $part : "{$disposition};{$part}"; if ( strlen( $new ) <= 255 ) { - $res = $new; + $disposition = $new; } else { break; // too long; sigh } @@ -986,6 +992,20 @@ class SwiftFileBackend extends FileBackendStore { $this->cheapCache->set( $path, 'stat', $val ); } + protected function doGetFileXAttributes( array $params ) { + $stat = $this->getFileStat( $params ); + if ( $stat ) { + if ( !isset( $stat['xattr'] ) ) { + // Stat entries filled by file listings don't include metadata/headers + $this->clearCache( array( $params['src'] ) ); + $stat = $this->getFileStat( $params ); + } + return $stat['xattr']; + } else { + return false; + } + } + protected function doGetFileSha1base36( array $params ) { $stat = $this->getFileStat( $params ); if ( $stat ) { |