* @return Array List of relative paths of dirs directly under $dir
*/
public function getDirListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
+ $dirs = array();
+ if ( $after === INF ) {
+ return $dirs; // nothing more
+ }
wfProfileIn( __METHOD__ . '-' . $this->name );
- $dirs = array();
try {
$container = $this->getContainer( $fullCont );
$prefix = ( $dir == '' ) ? null : "{$dir}/";
if ( substr( $object, -1 ) === '/' ) {
$dirs[] = $object; // directories end in '/'
}
- $after = $object; // update last item
}
// Recursive: list all dirs under $dir and its subdirs
} else {
}
$lastDir = $objectDir;
}
- $after = $object; // update last item
}
}
+ if ( count( $objects ) < $limit ) {
+ $after = INF; // avoid a second RTT
+ } else {
+ $after = end( $objects ); // update last item
+ }
} catch ( NoSuchContainerException $e ) {
} catch ( CloudFilesException $e ) { // some other exception?
$this->handleException( $e, null, __METHOD__,
* @return Array List of relative paths of files under $dir
*/
public function getFileListPageInternal( $fullCont, $dir, &$after, $limit, array $params ) {
+ $files = array();
+ if ( $after === INF ) {
+ return $files; // nothing more
+ }
wfProfileIn( __METHOD__ . '-' . $this->name );
- $files = array();
try {
$container = $this->getContainer( $fullCont );
$prefix = ( $dir == '' ) ? null : "{$dir}/";
}
// Recursive: list all files under $dir and its subdirs
} else { // files
- $files = $container->list_objects( $limit, $after, $prefix );
+ $objects = $container->list_objects( $limit, $after, $prefix );
+ $files = $objects;
+ }
+ if ( count( $objects ) < $limit ) {
+ $after = INF; // avoid a second RTT
+ } else {
+ $after = end( $objects ); // update last item
}
- $after = end( $files ); // update last item
- reset( $files ); // reset pointer
} catch ( NoSuchContainerException $e ) {
} catch ( CloudFilesException $e ) { // some other exception?
$this->handleException( $e, null, __METHOD__,