00001 <?php
00002
00003 require( 'commandLine.inc' );
00004
00005 $batchSize = 1000;
00006 $start = '';
00007 $dbr = wfGetDB( DB_SLAVE );
00008 $localRepo = RepoGroup::singleton()->getLocalRepo();
00009
00010 $numImages = 0;
00011 $numGood = 0;
00012
00013 do {
00014 $res = $dbr->select( 'image', '*', array( 'img_name > ' . $dbr->addQuotes( $start ) ),
00015 'checkImages.php', array( 'LIMIT' => $batchSize ) );
00016 foreach ( $res as $row ) {
00017 $numImages++;
00018 $start = $row->img_name;
00019 $file = $localRepo->newFileFromRow( $row );
00020 $path = $file->getPath();
00021 if ( !$path ) {
00022 echo "{$row->img_name}: not locally accessible\n";
00023 continue;
00024 }
00025 $stat = @stat( $file->getPath() );
00026 if ( !$stat ) {
00027 echo "{$row->img_name}: missing\n";
00028 continue;
00029 }
00030
00031 if ( $stat['mode'] & 040000 ) {
00032 echo "{$row->img_name}: is a directory\n";
00033 continue;
00034 }
00035
00036 if ( $stat['size'] == 0 && $row->img_size != 0 ) {
00037 echo "{$row->img_name}: truncated, was {$row->img_size}\n";
00038 continue;
00039 }
00040
00041 if ( $stat['size'] != $row->img_size ) {
00042 echo "{$row->img_name}: size mismatch DB={$row->img_size}, actual={$stat['size']}\n";
00043 continue;
00044 }
00045
00046 $numGood++;
00047 }
00048
00049 } while ( $res->numRows() );
00050
00051 echo "Good images: $numGood/$numImages\n";