Made findMissingFiles use preloadFileStat() on old versions too to speed it up
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 28 Aug 2014 21:58:29 +0000 (14:58 -0700)
committerOri.livneh <ori@wikimedia.org>
Fri, 29 Aug 2014 17:50:41 +0000 (17:50 +0000)
Change-Id: I03133c146f5a4f07f27b26dd033d6c93b72aea04

maintenance/findMissingFiles.php

index 4bb9dc7..8a8bcb1 100644 (file)
@@ -85,14 +85,22 @@ class FindMissingFiles extends Maintenance {
                                        array( 'oi_name' => array_keys( $pathsByName ) ),
                                        __METHOD__
                                );
+
+                               $checkPaths = array();
                                foreach ( $ores as $row ) {
                                        if ( !strlen( $row->oi_archive_name ) ) {
                                                continue; // broken row
                                        }
                                        $file = $repo->newFromArchiveName( $row->oi_name, $row->oi_archive_name );
-                                       $path = $file->getPath();
-                                       if ( $be->fileExists( array( 'src' => $path ) ) === false ) {
-                                               $this->output( "$path\n" );
+                                       $checkPaths[] = $file->getPath();
+                               }
+
+                               foreach ( array_chunk( $checkPaths, $this->mBatchSize ) as $paths ) {
+                                       $be->preloadFileStat( array( 'srcs' => $paths ) );
+                                       foreach ( $paths as $path ) {
+                                               if ( $be->fileExists( array( 'src' => $path ) ) === false ) {
+                                                       $this->output( "$path\n" );
+                                               }
                                        }
                                }
                        }