X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcopyFileBackend.php;h=13301edc2e9639becb3a7f070fc15fa2ac2912f3;hb=9cf0a3d81ffd77202450731f6b1d38e2fe129022;hp=6846edf701e59dea5bfa8f7f9a32a63bb727216f;hpb=c6894adefc1aedab584091500f93eff9eab94c88;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/copyFileBackend.php b/maintenance/copyFileBackend.php index 6846edf701..13301edc2e 100644 --- a/maintenance/copyFileBackend.php +++ b/maintenance/copyFileBackend.php @@ -21,7 +21,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** * Copy all files in one container of one backend to another. @@ -56,7 +56,7 @@ class CopyFileBackend extends Maintenance { $src = FileBackendGroup::singleton()->get( $this->getOption( 'src' ) ); $dst = FileBackendGroup::singleton()->get( $this->getOption( 'dst' ) ); $containers = explode( '|', $this->getOption( 'containers' ) ); - $subDir = $this->getOption( rtrim( 'subdir', '/' ), '' ); + $subDir = rtrim( $this->getOption( 'subdir', '' ), '/' ); $rateFile = $this->getOption( 'ratefile' ); @@ -158,6 +158,7 @@ class CopyFileBackend extends Maintenance { $ops = array(); $fsFiles = array(); $copiedRel = array(); // for output message + $wikiId = $src->getWikiId(); // Download the batch of source files into backend cache... if ( $this->hasOption( 'missingonly' ) ) { @@ -177,7 +178,7 @@ class CopyFileBackend extends Maintenance { $srcPath = $src->getRootStoragePath() . "/$backendRel/$srcPathRel"; $dstPath = $dst->getRootStoragePath() . "/$backendRel/$srcPathRel"; if ( $this->hasOption( 'utf8only' ) && !mb_check_encoding( $srcPath, 'UTF-8' ) ) { - $this->error( "Detected illegal (non-UTF8) path for $srcPath." ); + $this->error( "$wikiId: Detected illegal (non-UTF8) path for $srcPath." ); continue; } elseif ( !$this->hasOption( 'missingonly' ) && $this->filesAreSame( $src, $dst, $srcPath, $dstPath ) ) @@ -189,16 +190,18 @@ class CopyFileBackend extends Maintenance { ? $fsFiles[$srcPath] : $src->getLocalReference( array( 'src' => $srcPath, 'latest' => 1 ) ); if ( !$fsFile ) { - if ( $src->fileExists( array( 'src' => $srcPath ) ) === false ) { - $this->error( "File '$srcPath' was listed be must have been deleted." ); + $src->clearCache( array( $srcPath ) ); + if ( $src->fileExists( array( 'src' => $srcPath, 'latest' => 1 ) ) === false ) { + $this->error( "$wikiId: File '$srcPath' was listed but does not exist." ); } else { - $this->error( "Could not get local copy of $srcPath.", 1 ); // die + $this->error( "$wikiId: Could not get local copy of $srcPath." ); } + continue; } elseif ( !$fsFile->exists() ) { // FSFileBackends just return the path for getLocalReference() and paths with // illegal slashes may get normalized to a different path. This can cause the // local reference to not exist...skip these broken files. - $this->error( "Detected possible illegal path for $srcPath." ); + $this->error( "$wikiId: Detected possible illegal path for $srcPath." ); continue; } $fsFiles[] = $fsFile; // keep TempFSFile objects alive as needed @@ -206,7 +209,7 @@ class CopyFileBackend extends Maintenance { $status = $dst->prepare( array( 'dir' => dirname( $dstPath ), 'bypassReadOnly' => 1 ) ); if ( !$status->isOK() ) { $this->error( print_r( $status->getErrorsArray(), true ) ); - $this->error( "Could not copy $srcPath to $dstPath.", 1 ); // die + $this->error( "$wikiId: Could not copy $srcPath to $dstPath.", 1 ); // die } $ops[] = array( 'op' => 'store', 'src' => $fsFile->getPath(), 'dst' => $dstPath, 'overwrite' => 1 ); @@ -223,7 +226,7 @@ class CopyFileBackend extends Maintenance { $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 + $this->error( "$wikiId: Could not copy file batch.", 1 ); // die } elseif ( count( $copiedRel ) ) { $this->output( "\nCopied these file(s) [{$ellapsed_ms}ms]:\n" . implode( "\n", $copiedRel ) . "\n\n" );