- foreach ( array_chunk( $params['srcs'], $params['concurrency'] ) as $pathBatch ) {
- $reqs = array(); // (path => op)
-
- foreach ( $pathBatch as $path ) { // each path in this concurrent batch
- list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $path );
- if ( $srcRel === null || !$auth ) {
- $tmpFiles[$path] = null;
- continue;
- }
- $tmpFile = null;
- // Get source file extension
- $ext = FileBackend::extensionFromPath( $path );
- // Create a new temporary file...
- $tmpFile = TempFSFile::factory( 'localcopy_', $ext );
- if ( $tmpFile ) {
- $handle = fopen( $tmpFile->getPath(), 'wb' );
- if ( $handle ) {
- $reqs[$path] = array(
- 'method' => 'GET',
- 'url' => $this->storageUrl( $auth, $srcCont, $srcRel ),
- 'headers' => $this->authTokenHeaders( $auth )
- + $this->headersFromParams( $params ),
- 'stream' => $handle,
- );
- } else {
- $tmpFile = null;
- }
- }
- $tmpFiles[$path] = $tmpFile;
- }