Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git
FilePage.php
$this->git->stream( $targetHash, function( $d ) use ( &$buffer ) {
-
if( strlen( $buffer ) < 12 ) $buffer .= $d;
} );
$filename = $_GET['name'] ?? '';
$category = MediaTypeSniffer::isCategory( $buffer, $filename );
$mediaType = MediaTypeSniffer::isMediaType( $buffer, $filename );
+
+ // --- DIAGNOSTIC BLOCK ---
+ echo "<pre style='background:#111;color:#0f0;padding:15px;border:3px solid #f00;margin:10px 0;'>";
+ echo "DEBUG FOR: " . htmlspecialchars($filename) . "\n";
+ echo "EXPECTED SIZE: " . $size . " bytes\n";
+ echo "BUFFER HEX (12B): " . bin2hex($buffer) . "\n";
+ echo "CATEGORY: " . var_export($category, true) . "\n";
+ echo "MEDIA TYPE: " . var_export($mediaType, true) . "\n";
+
+ // Check if content-type detection logic is forcing a binary state
+ $isBinary = MediaTypeSniffer::isBinary($buffer, $filename);
+ echo "IS_BINARY EVAL: " . ($isBinary ? 'TRUE' : 'FALSE') . "\n";
+
+ // Test if the full stream actually produces data
+ $fullContent = '';
+ $this->git->stream($targetHash, function($d) use (&$fullContent) { $fullContent .= $d; });
+ echo "FULL STREAM LENGTH: " . strlen($fullContent) . " bytes\n";
+ echo "FULL CONTENT (HEX): " . bin2hex(substr($fullContent, 0, 32)) . "...\n";
+ echo "</pre>";
+ // --- END DIAGNOSTIC ---
$this->renderBreadcrumbs( $targetHash, 'File' );

Adds diagnostics

Author Dave Jarvis <email>
Date 2026-02-09 17:55:29 GMT-0800
Commit dd6ef3d43022f31c3c93c3b0655ea590fd252787
Parent 50376a8
Delta 20 lines added, 1 line removed, 19-line increase