jenkins-bot has submitted this change and it was merged.

Change subject: Avoid HEAD requests for files missing from the destination
......................................................................


Avoid HEAD requests for files missing from the destination

Change-Id: I8a3d2ddeb650c800d1e4af144d5cd2cb23cd8744
---
M maintenance/copyFileBackend.php
1 file changed, 11 insertions(+), 5 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php
index 21ef4ff..49af0b8 100644
--- a/maintenance/copyFileBackend.php
+++ b/maintenance/copyFileBackend.php
@@ -35,7 +35,8 @@
  * @ingroup Maintenance
  */
 class CopyFileBackend extends Maintenance {
-       protected $statCache = array();
+       /** @var Array|null (path sha1 => stat) Pre-computed dst stat entries 
from listings */
+       protected $statCache = null;
 
        public function __construct() {
                parent::__construct();
@@ -98,7 +99,7 @@
                                if ( $dstPathsRel === null ) {
                                        $this->error( "Could not list files in 
$container.", 1 ); // die
                                }
-                               $this->statCache = array(); // clear
+                               $this->statCache = array();
                                foreach ( $dstPathsRel as $dstPathRel ) {
                                        $path = $dst->getRootStoragePath() . 
"/$backendRel/$dstPathRel";
                                        $this->statCache[sha1( $path )] = 
$dst->getFileStat( array( 'src' => $path ) );
@@ -338,9 +339,14 @@
                $skipHash = $this->hasOption( 'skiphash' );
                $srcStat = $src->getFileStat( array( 'src' => $sPath ) );
                $dPathSha1 = sha1( $dPath );
-               $dstStat = isset( $this->statCache[$dPathSha1] )
-                       ? $this->statCache[$dPathSha1]
-                       : $dst->getFileStat( array( 'src' => $dPath ) );
+               if ( $this->statCache !== null ) {
+                       // All dst files are already in stat cache
+                       $dstStat = isset( $this->statCache[$dPathSha1] )
+                               ? $this->statCache[$dPathSha1]
+                               : false;
+               } else {
+                       $dstStat = $dst->getFileStat( array( 'src' => $dPath ) 
);
+               }
                return (
                        is_array( $srcStat ) // sanity check that source exists
                        && is_array( $dstStat ) // dest exists

-- 
To view, visit https://gerrit.wikimedia.org/r/95073
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8a3d2ddeb650c800d1e4af144d5cd2cb23cd8744
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to