[FileBackend] Only show "copied file(s)" for files the script had to copy.
authorAaron <aschulz@wikimedia.org>
Tue, 10 Jul 2012 19:20:55 +0000 (12:20 -0700)
committerAaron <aschulz@wikimedia.org>
Tue, 10 Jul 2012 19:21:11 +0000 (12:21 -0700)
Change-Id: I22741303e05d6ea50d33875d9f7438d2b3905b18

maintenance/copyFileBackend.php

index 1f72e33..0af1aa7 100644 (file)
@@ -104,6 +104,7 @@ class CopyFileBackend extends Maintenance {
        ) {
                $ops = array();
                $fsFiles = array();
+               $copiedRel = array(); // for output message
                foreach ( $srcPathsRel as $srcPathRel ) {
                        $srcPath = $src->getRootStoragePath() . "/$backendRel/$srcPathRel";
                        $dstPath = $dst->getRootStoragePath() . "/$backendRel/$srcPathRel";
@@ -125,6 +126,7 @@ class CopyFileBackend extends Maintenance {
                        }
                        $ops[] = array( 'op' => 'store',
                                'src' => $fsFile->getPath(), 'dst' => $dstPath, 'overwrite' => 1 );
+                       $copiedRel[] = $srcPathRel;
                }
 
                $t_start = microtime( true );
@@ -133,9 +135,9 @@ class CopyFileBackend extends Maintenance {
                if ( !$status->isOK() ) {
                        $this->error( print_r( $status->getErrorsArray(), true ) );
                        $this->error( "Could not copy file batch.", 1 ); // die
-               } else {
+               } elseif ( count( $copiedRel ) ) {
                        $this->output( "\nCopied these file(s) [{$ellapsed_ms}ms]:\n" .
-                               implode( "\n", $srcPathsRel ) . "\n\n" );
+                               implode( "\n", $copiedRel ) . "\n\n" );
                }
        }