| Author | Dave Jarvis <email> |
|---|---|
| Date | 2026-02-14 14:57:16 GMT-0800 |
| Commit | 7813282484c27913b18c9a78687f795d6378d36b |
| Parent | e8b43bf |
| $buffer = $this->isDir ? '' : $contents; | ||
| - $this->mediaType = MediaTypeSniffer::isMediaType($buffer, $name); | ||
| - $this->category = MediaTypeSniffer::isCategory($buffer, $name); | ||
| - $this->binary = MediaTypeSniffer::isBinary($buffer, $name); | ||
| + $this->mediaType = MediaTypeSniffer::isMediaType( $buffer ); | ||
| + $this->category = MediaTypeSniffer::isCategory( $buffer, $name ); | ||
| + $this->binary = MediaTypeSniffer::isBinary( $buffer ); | ||
| $this->icon = $this->resolveIcon(); | ||
| } |
| ]; | ||
| - public static function isMediaType( | ||
| - string $buffer, | ||
| - string $filename = '' | ||
| - ): string { | ||
| + public static function isMediaType( string $buffer ): string { | ||
| $finfo = new finfo( FILEINFO_MIME_TYPE ); | ||
| $mediaType = $finfo->buffer( $buffer ); | ||
| return $mediaType ?: 'application/octet-stream'; | ||
| } | ||
| public static function isCategory( | ||
| string $buffer, | ||
| string $filename = '' | ||
| ): string { | ||
| - $mediaType = self::isMediaType( $buffer, $filename ); | ||
| + $mediaType = self::isMediaType( $buffer ); | ||
| $parts = explode( '/', $mediaType ); | ||
| } | ||
| - public static function isBinary( | ||
| - string $buffer, | ||
| - string $filename = '' | ||
| - ): bool { | ||
| - return !str_starts_with( | ||
| - self::isMediaType( $buffer, $filename ), | ||
| - 'text/' | ||
| - ); | ||
| + public static function isBinary( string $buffer ): bool { | ||
| + return !str_starts_with( self::isMediaType( $buffer ), 'text/' ); | ||
| } | ||
| } | ||
| - public function peek( string $sha, int $length = 12 ): string { | ||
| + public function peek( string $sha, int $length = 255 ): string { | ||
| $size = $this->packs->getSize( $sha ); | ||
| $isDirectory = $mode === '40000' || $mode === '040000'; | ||
| $size = $isDirectory ? 0 : $this->getObjectSize( $sha ); | ||
| - $contents = $isDirectory ? '' : $this->peek( $sha, 255 ); | ||
| + $contents = $isDirectory ? '' : $this->peek( $sha ); | ||
| $callback( new File( $name, $sha, $mode, 0, $size, $contents ) ); | ||
| Delta | 9 lines added, 18 lines removed, 9-line decrease |
|---|