From: Aaron Date: Wed, 11 Jul 2012 23:34:43 +0000 (-0700) Subject: [FileBackend] Added hash skipping option to speed up script. X-Git-Tag: 1.31.0-rc.0~23068 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=46992c8bb4e520e75b128936ba790b0475c9c73e;p=lhc%2Fweb%2Fwiklou.git [FileBackend] Added hash skipping option to speed up script. Change-Id: If810bbdeffdbfa37a3609992c3e8038ee4deebe6 --- diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php index 0af1aa7d18..8db0a7f4bd 100644 --- a/maintenance/copyFileBackend.php +++ b/maintenance/copyFileBackend.php @@ -42,7 +42,8 @@ class CopyFileBackend extends Maintenance { $this->addOption( 'dst', 'Backend where files should be copied to', true, true ); $this->addOption( 'containers', 'Pipe separated list of containers', true, true ); $this->addOption( 'subdir', 'Only do items in this child directory', false, true ); - $this->addOption( 'ratefile', 'File to check periodically for batch size.', false, true ); + $this->addOption( 'ratefile', 'File to check periodically for batch size', false, true ); + $this->addOption( 'skiphash', 'Skip SHA-1 sync checks for files' ); $this->setBatchSize( 50 ); } @@ -142,14 +143,15 @@ class CopyFileBackend extends Maintenance { } protected function filesAreSame( FileBackend $src, FileBackend $dst, $sPath, $dPath ) { + $skipHash = $this->hasOption( 'skiphash' ); return ( ( $src->fileExists( array( 'src' => $sPath, 'latest' => 1 ) ) === $dst->fileExists( array( 'src' => $dPath, 'latest' => 1 ) ) // short-circuit ) && ( $src->getFileSize( array( 'src' => $sPath, 'latest' => 1 ) ) === $dst->getFileSize( array( 'src' => $dPath, 'latest' => 1 ) ) // short-circuit - ) && ( $src->getFileSha1Base36( array( 'src' => $sPath, 'latest' => 1 ) ) + ) && ( $skipHash || ( $src->getFileSha1Base36( array( 'src' => $sPath, 'latest' => 1 ) ) === $dst->getFileSha1Base36( array( 'src' => $dPath, 'latest' => 1 ) ) - ) + ) ) ); } }