* Fixed bugs in SwiftFileBackend file listing code

* Clear container cache in SwiftFileBackend when clearCache() is called
* Updated a comment and fixed a comment typo
This commit is contained in:
Aaron Schulz 2012-01-22 00:06:18 +00:00
parent 4790826b97
commit 2d1d7f644b
3 changed files with 16 additions and 4 deletions

View file

@ -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
);
}

View file

@ -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 );
}

View file

@ -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() {