From: Aaron Date: Tue, 10 Jul 2012 18:33:24 +0000 (-0700) Subject: [FileBackend] Improved copy/sync script output. X-Git-Tag: 1.31.0-rc.0~23080^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=082cde1f9dc5d3a90ad9aae0cb8a9f2bf9ade02e;p=lhc%2Fweb%2Fwiklou.git [FileBackend] Improved copy/sync script output. Change-Id: I5f76fdb579cf17959093e7a8659839e8b8829b1c --- diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php index 78ffb20205..1f72e33226 100644 --- a/maintenance/copyFileBackend.php +++ b/maintenance/copyFileBackend.php @@ -127,12 +127,15 @@ class CopyFileBackend extends Maintenance { 'src' => $fsFile->getPath(), 'dst' => $dstPath, 'overwrite' => 1 ); } + $t_start = microtime( true ); $status = $dst->doOperations( $ops, array( 'nonJournaled' => 1 ) ); + $ellapsed_ms = floor( ( microtime( true ) - $t_start ) * 1000 ); if ( !$status->isOK() ) { $this->error( print_r( $status->getErrorsArray(), true ) ); $this->error( "Could not copy file batch.", 1 ); // die } else { - $this->output( "Copied these file(s):\n" . implode( "\n", $srcPathsRel ) . "\n\n" ); + $this->output( "\nCopied these file(s) [{$ellapsed_ms}ms]:\n" . + implode( "\n", $srcPathsRel ) . "\n\n" ); } } diff --git a/maintenance/syncFileBackend.php b/maintenance/syncFileBackend.php index 0d5c9deec6..1af33e6ed4 100644 --- a/maintenance/syncFileBackend.php +++ b/maintenance/syncFileBackend.php @@ -39,12 +39,11 @@ class SyncFileBackend extends Maintenance { $src = FileBackendGroup::singleton()->get( $this->getOption( 'src' ) ); $dst = FileBackendGroup::singleton()->get( $this->getOption( 'dst' ) ); - $posFile = $this->getOption( 'posdir' ) - ? $this->getOption( 'posdir' ) . '/' . wfWikiID() - : false; + $posDir = $this->getOption( 'posdir' ); + $posFile = $posDir ? $posDir . '/' . wfWikiID() : false; $start = $this->getOption( 'start', 0 ); - if ( !$start && $posFile ) { + if ( !$start && $posFile && is_dir( $posDir ) ) { $start = is_file( $posFile ) ? (int)trim( file_get_contents( $posFile ) ) : 0; @@ -66,8 +65,11 @@ class SyncFileBackend extends Maintenance { // Update the sync position file if ( $startFromPosFile && $lastOKPos >= $start ) { // successfully advanced - file_put_contents( $posFile, $lastOKPos, LOCK_EX ); - $this->output( "Updated journal position file.\n" ); + if ( file_put_contents( $posFile, $lastOKPos, LOCK_EX ) !== false ) { + $this->output( "Updated journal position file.\n" ); + } else { + $this->output( "Could not update journal position file.\n" ); + } } if ( $lastOKPos === false ) { @@ -198,10 +200,13 @@ class SyncFileBackend extends Maintenance { } } + $t_start = microtime( true ); $status->merge( $dst->doOperations( $ops, array( 'nonLocking' => 1, 'nonJournaled' => 1 ) ) ); + $ellapsed_ms = floor( ( microtime( true ) - $t_start ) * 1000 ); if ( $status->isOK() && $this->getOption( 'verbose' ) ) { - $this->output( "Synchronized these file(s):\n" . implode( "\n", $dPaths ) . "\n" ); + $this->output( "Synchronized these file(s) [{$ellapsed_ms}ms]:\n" . + implode( "\n", $dPaths ) . "\n" ); } return $status;