Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/61738
Change subject: Reduced memory usage a bit for copyFileBackend.php with
--missingonly.
......................................................................
Reduced memory usage a bit for copyFileBackend.php with --missingonly.
Change-Id: Iae650b5c3a5f99c5b2e31e29c276957ea6b8bb50
---
M maintenance/copyFileBackend.php
1 file changed, 13 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/38/61738/1
diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php
index f2c4ac5..fe422b3 100644
--- a/maintenance/copyFileBackend.php
+++ b/maintenance/copyFileBackend.php
@@ -79,24 +79,28 @@
// Do a listing comparison if specified
if ( $this->hasOption( 'missingonly' ) ) {
- $relFilesSrc = array();
- $relFilesDst = array();
- foreach ( $srcPathsRel as $srcPathRel ) {
- $relFilesSrc[] = $srcPathRel;
- }
$dstPathsRel = $dst->getFileList( array(
'dir' => $dst->getRootStoragePath() .
"/$backendRel" ) );
if ( $dstPathsRel === null ) {
$this->error( "Could not list files in
$container.", 1 ); // die
}
+ // Get the list of destination files
+ $relFilesDstSha1 = array();
foreach ( $dstPathsRel as $dstPathRel ) {
- $relFilesDst[] = $dstPathRel;
+ $relFilesDstSha1[sha1( $dstPathRel )] =
1;
}
+ unset( $dstPathsRel ); // free
+ // Get the list of missing files
+ $missingPathsRel = array();
+ foreach ( $srcPathsRel as $srcPathRel ) {
+ if ( !isset( $relFilesDstSha1[sha1(
$srcPathRel )] ) ) {
+ $missingPathsRel[] =
$srcPathRel;
+ }
+ }
+ unset( $srcPathsRel ); // free
// Only copy the missing files over in the next
loop
- $srcPathsRel = array_diff( $relFilesSrc,
$relFilesDst );
+ $srcPathsRel = $missingPathsRel;
$this->output( count( $srcPathsRel ) . "
file(s) need to be copied.\n" );
- unset( $relFilesSrc );
- unset( $relFilesDst );
}
$batchPaths = array();
--
To view, visit https://gerrit.wikimedia.org/r/61738
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae650b5c3a5f99c5b2e31e29c276957ea6b8bb50
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits