Make Swift iterators throw errors on failure
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 7 Nov 2015 00:10:05 +0000 (16:10 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 7 Nov 2015 00:10:05 +0000 (16:10 -0800)
This is in line with FSFileBackend and is provides the calling
loop of a way to know the listing failed, rather than just
giving incomplete information.

Change-Id: I34c66d9dbf84e5f33982d17e61364c1595d3e9f7

includes/filebackend/SwiftFileBackend.php

index 8097549..72a877d 100644 (file)
@@ -861,7 +861,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !empty( $params['topOnly'] ) ) {
                        $status = $this->objectListing( $fullCont, 'names', $limit, $after, $prefix, '/' );
                        if ( !$status->isOk() ) {
-                               return $dirs; // error
+                               throw new FileBackendError( "Iterator page I/O error: {$status->getMessage()}" );
                        }
                        $objects = $status->value;
                        foreach ( $objects as $object ) { // files and directories
@@ -880,7 +880,7 @@ class SwiftFileBackend extends FileBackendStore {
                        $status = $this->objectListing( $fullCont, 'names', $limit, $after, $prefix );
 
                        if ( !$status->isOk() ) {
-                               return $dirs; // error
+                               throw new FileBackendError( "Iterator page I/O error: {$status->getMessage()}" );
                        }
 
                        $objects = $status->value;
@@ -956,7 +956,7 @@ class SwiftFileBackend extends FileBackendStore {
 
                // Reformat this list into a list of (name, stat array or null) entries
                if ( !$status->isOk() ) {
-                       return $files; // error
+                       throw new FileBackendError( "Iterator page I/O error: {$status->getMessage()}" );
                }
 
                $objects = $status->value;