From: Aaron Schulz Date: Sun, 22 Jan 2012 00:06:18 +0000 (+0000) Subject: * Fixed bugs in SwiftFileBackend file listing code X-Git-Tag: 1.31.0-rc.0~25142 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22lang_raccourcis%22%2C%22module=%24nom_module%22%29%20.%20%22?a=commitdiff_plain;h=2d1d7f644bb50983381590765cb03b1bececcbb0;p=lhc%2Fweb%2Fwiklou.git * Fixed bugs in SwiftFileBackend file listing code * Clear container cache in SwiftFileBackend when clearCache() is called * Updated a comment and fixed a comment typo --- diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 7e92b4db12..e7608ca4f2 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -1084,7 +1084,7 @@ class FileRepo { 'dst' => $archivePath, // We may have 2+ identical files being deleted, // all of which will map to the same destination file - 'overwriteSame' => true + 'overwriteSame' => true // also see bug 31792 ); } diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index 97ab13d3ac..0e07923485 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -1300,7 +1300,7 @@ abstract class FileBackend extends FileBackendBase { // This accounts for Swift and S3 restrictions while leaving room // for things like '.xxx' (hex shard chars) or '.seg' (segments). // Note that matching strings URL encode to the same string; - // in Swift, the length resriction is *after* URL encoding. + // in Swift, the length restriction is *after* URL encoding. return preg_match( '/^[a-z0-9][a-z0-9-_]{0,199}$/i', $container ); } diff --git a/includes/filerepo/backend/SwiftFileBackend.php b/includes/filerepo/backend/SwiftFileBackend.php index 29c0fa8c62..9c9a551442 100644 --- a/includes/filerepo/backend/SwiftFileBackend.php +++ b/includes/filerepo/backend/SwiftFileBackend.php @@ -508,7 +508,8 @@ class SwiftFileBackend extends FileBackend { try { $container = $this->getContainer( $fullCont ); - $files = $container->list_objects( $limit, $after, "{$dir}/" ); + $prefix = ( $dir == '' ) ? null : "{$dir}/"; + $files = $container->list_objects( $limit, $after, $prefix ); } catch ( NoSuchContainerException $e ) { } catch ( NoSuchObjectException $e ) { } catch ( InvalidResponseException $e ) { @@ -685,6 +686,13 @@ class SwiftFileBackend extends FileBackend { return $this->conn; } + /** + * @see FileBackend::doClearCache() + */ + protected function doClearCache( array $paths = null ) { + $this->connContainers = array(); // clear container object cache + } + /** * Get a Swift container object, possibly from process cache. * Use $reCache if the file count or byte count is needed. @@ -784,7 +792,11 @@ class SwiftFileBackendFileList implements Iterator { if ( substr( $this->dir, -1 ) === '/' ) { $this->dir = substr( $this->dir, 0, -1 ); // remove trailing slash } - $this->suffixStart = strlen( $dir ) + 1; // size of "path/to/dir/" + if ( $this->dir == '' ) { // whole container + $this->suffixStart = 0; + } else { // dir within container + $this->suffixStart = strlen( $dir ) + 1; // size of "path/to/dir/" + } } public function current() {