| | if( $type === 6 ) { |
| | $neg = $this->readOffsetDelta( $handle ); |
| | - $deltaPos = ftell( $handle ); |
| | - $baseSize = $this->decoder->readDeltaBaseSize( $handle ); |
| | + $baseSize = $this->getSize( $pool, $packFile, $offset - $neg ); |
| | |
| | if( $baseSize > self::MAX_BASE_RAM ) { |
 |
| | |
| | if( $tmpHandle !== false ) { |
| | - fseek( $handle, $deltaPos ); |
| | - |
| | yield from $this->decoder->applyStreamGenerator( |
| | $handle, |
| | $tmpHandle |
| | ); |
| | |
| | fclose( $tmpHandle ); |
| | } |
| | } else { |
| | - $chunks = []; |
| | + $readShaBaseFn = function( string $sha, int $cap ) use ( $streamShaFn, $depth ): string { |
| | + $chunks = []; |
| | |
| | - foreach( $this->streamEntryGenerator( |
| | - $pool, |
| | - $packFile, |
| | - $offset - $neg, |
| | - $depth + 1, |
| | - $getSizeShaFn, |
| | - $streamShaFn |
| | - ) as $chunk ) { |
| | - $chunks[] = $chunk; |
| | - } |
| | + foreach( $streamShaFn( $sha, $depth + 1 ) as $chunk ) { |
| | + $chunks[] = $chunk; |
| | + } |
| | |
| | - $base = implode( '', $chunks ); |
| | + $result = implode( '', $chunks ); |
| | |
| | - fseek( $handle, $deltaPos ); |
| | + return $cap > 0 && strlen( $result ) > $cap ? substr( $result, 0, $cap ) : $result; |
| | + }; |
| | + |
| | + $base = $this->read( $pool, $packFile, $offset - $neg, 0, $readShaBaseFn ); |
| | |
| | yield from $this->decoder->applyStreamGenerator( |
| | $handle, |
| | $base |
| | ); |
| | } |
| | } else { |
| | $baseSha = bin2hex( fread( $handle, 20 ) ); |
| | - $deltaPos = ftell( $handle ); |
| | - $baseSize = $this->decoder->readDeltaBaseSize( $handle ); |
| | + $baseSize = $getSizeShaFn( $baseSha ); |
| | |
| | if( $baseSize > self::MAX_BASE_RAM ) { |
 |
| | if( $written ) { |
| | rewind( $tmpHandle ); |
| | - |
| | - fseek( $handle, $deltaPos ); |
| | |
| | yield from $this->decoder->applyStreamGenerator( |
 |
| | if( $written ) { |
| | $base = implode( '', $chunks ); |
| | - |
| | - fseek( $handle, $deltaPos ); |
| | |
| | yield from $this->decoder->applyStreamGenerator( |