summaryrefslogtreecommitdiff
path: root/maintenance/copyFileBackend.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/copyFileBackend.php')
-rw-r--r--maintenance/copyFileBackend.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php
index aebdee17..f2c4ac54 100644
--- a/maintenance/copyFileBackend.php
+++ b/maintenance/copyFileBackend.php
@@ -134,6 +134,21 @@ class CopyFileBackend extends Maintenance {
$ops = array();
$fsFiles = array();
$copiedRel = array(); // for output message
+
+ // Download the batch of source files into backend cache...
+ if ( $this->hasOption( 'missingonly' ) ) {
+ $srcPaths = array();
+ foreach ( $srcPathsRel as $srcPathRel ) {
+ $srcPaths[] = $src->getRootStoragePath() . "/$backendRel/$srcPathRel";
+ }
+ $t_start = microtime( true );
+ $fsFiles = $src->getLocalReferenceMulti( array( 'srcs' => $srcPaths, 'latest' => 1 ) );
+ $ellapsed_ms = floor( ( microtime( true ) - $t_start ) * 1000 );
+ $this->output( "\nDownloaded these file(s) [{$ellapsed_ms}ms]:\n" .
+ implode( "\n", $srcPaths ) . "\n\n" );
+ }
+
+ // Determine what files need to be copied over...
foreach ( $srcPathsRel as $srcPathRel ) {
$srcPath = $src->getRootStoragePath() . "/$backendRel/$srcPathRel";
$dstPath = $dst->getRootStoragePath() . "/$backendRel/$srcPathRel";
@@ -144,8 +159,9 @@ class CopyFileBackend extends Maintenance {
$this->output( "Already have $srcPathRel.\n" );
continue; // assume already copied...
}
- // Note: getLocalReference() is fast for FS backends
- $fsFile = $src->getLocalReference( array( 'src' => $srcPath, 'latest' => 1 ) );
+ $fsFile = array_key_exists( $srcPath, $fsFiles )
+ ? $fsFiles[$srcPath]
+ : $src->getLocalReference( array( 'src' => $srcPath, 'latest' => 1 ) );
if ( !$fsFile ) {
$this->error( "Could not get local copy of $srcPath.", 1 ); // die
} elseif ( !$fsFile->exists() ) {
@@ -167,6 +183,7 @@ class CopyFileBackend extends Maintenance {
$copiedRel[] = $srcPathRel;
}
+ // Copy in the batch of source files...
$t_start = microtime( true );
$status = $dst->doQuickOperations( $ops, array( 'bypassReadOnly' => 1 ) );
if ( !$status->isOK() ) {