From 46992c8bb4e520e75b128936ba790b0475c9c73e Mon Sep 17 00:00:00 2001 From: Aaron Date: Wed, 11 Jul 2012 16:34:43 -0700 Subject: [PATCH] [FileBackend] Added hash skipping option to speed up script. Change-Id: If810bbdeffdbfa37a3609992c3e8038ee4deebe6 --- maintenance/copyFileBackend.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 ) ) - ) + ) ) ); } } -- 2.20.1