1) /** * @param FileBackendStore $backend * @param string $container Full storage container name * @param string $dir Storage directory relative to container * @param array $suffixes List of container shard suffixes * @param array $params */ public function __construct( FileBackendStore $backend, $container, $dir, array $suffixes, array $params ) { $this->backend = $backend; $this->container = $container; $this->directory = $dir; $this->params = $params; $iter = new AppendIterator(); foreach ( $suffixes as $suffix ) { $iter->append( $this->listFromShard( $this->container . $suffix ) ); } parent::__construct( $iter ); } public function accept() { $rel = $this->getInnerIterator()->current(); // path relative to given directory $path = $this->params['dir'] . "/{$rel}"; // full storage path if ( $this->backend->isSingleShardPathInternal( $path ) ) { return true; // path is only on one shard; no issue with duplicates } elseif ( isset( $this->multiShardPaths[$rel] ) ) { // Don't keep listing paths that are on multiple shards return false; } else { $this->multiShardPaths[$rel] = 1; return true; } } public function rewind() { parent::rewind(); $this->multiShardPaths = []; } /** * Get the list for a given container shard * * @param string $container Resolved container name * @return Iterator */ abstract protected function listFromShard( $container ); }