r109703 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109702‎ | r109703 | r109704 >
Date:00:06, 22 January 2012
Author:aaron
Status:ok
Tags:filebackend 
Comment:
* Fixed bugs in SwiftFileBackend file listing code
* Clear container cache in SwiftFileBackend when clearCache() is called
* Updated a comment and fixed a comment typo
Modified paths:
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/backend/FileBackend.php (modified) (history)
  • /trunk/phase3/includes/filerepo/backend/SwiftFileBackend.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/backend/SwiftFileBackend.php
@@ -508,7 +508,8 @@
509509
510510 try {
511511 $container = $this->getContainer( $fullCont );
512 - $files = $container->list_objects( $limit, $after, "{$dir}/" );
 512+ $prefix = ( $dir == '' ) ? null : "{$dir}/";
 513+ $files = $container->list_objects( $limit, $after, $prefix );
513514 } catch ( NoSuchContainerException $e ) {
514515 } catch ( NoSuchObjectException $e ) {
515516 } catch ( InvalidResponseException $e ) {
@@ -686,6 +687,13 @@
687688 }
688689
689690 /**
 691+ * @see FileBackend::doClearCache()
 692+ */
 693+ protected function doClearCache( array $paths = null ) {
 694+ $this->connContainers = array(); // clear container object cache
 695+ }
 696+
 697+ /**
690698 * Get a Swift container object, possibly from process cache.
691699 * Use $reCache if the file count or byte count is needed.
692700 *
@@ -784,7 +792,11 @@
785793 if ( substr( $this->dir, -1 ) === '/' ) {
786794 $this->dir = substr( $this->dir, 0, -1 ); // remove trailing slash
787795 }
788 - $this->suffixStart = strlen( $dir ) + 1; // size of "path/to/dir/"
 796+ if ( $this->dir == '' ) { // whole container
 797+ $this->suffixStart = 0;
 798+ } else { // dir within container
 799+ $this->suffixStart = strlen( $dir ) + 1; // size of "path/to/dir/"
 800+ }
789801 }
790802
791803 public function current() {
Index: trunk/phase3/includes/filerepo/backend/FileBackend.php
@@ -1300,7 +1300,7 @@
13011301 // This accounts for Swift and S3 restrictions while leaving room
13021302 // for things like '.xxx' (hex shard chars) or '.seg' (segments).
13031303 // Note that matching strings URL encode to the same string;
1304 - // in Swift, the length resriction is *after* URL encoding.
 1304+ // in Swift, the length restriction is *after* URL encoding.
13051305 return preg_match( '/^[a-z0-9][a-z0-9-_]{0,199}$/i', $container );
13061306 }
13071307
Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -1084,7 +1084,7 @@
10851085 'dst' => $archivePath,
10861086 // We may have 2+ identical files being deleted,
10871087 // all of which will map to the same destination file
1088 - 'overwriteSame' => true
 1088+ 'overwriteSame' => true // also see bug 31792
10891089 );
10901090 }
10911091

Status & tagging log