$batch = array();
$lastName = '';
do {
- $res = $dbw->select( 'image', array( 'img_name', 'img_sha1' ),
+ $res = $dbw->select( 'image',
+ array( 'img_name', 'img_sha1' ),
array_merge( array( 'img_name > ' . $dbw->addQuotes( $lastName ) ), $conds ),
__METHOD__,
array( 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'img_name' )
foreach ( $res as $row ) {
$lastName = $row->img_name;
- $sha1 = $row->img_sha1;
+ /** @var LocalFile $file */
+ $file = $repo->newFile( $row->img_name );
+ // Check in case SHA1 rows are not populated for some files
+ $sha1 = strlen( $row->img_sha1 ) ? $row->img_sha1 : $file->getSha1();
+
if ( !strlen( $sha1 ) ) {
- $this->error( "Image SHA-1 not set for {$row->img_name}." );
+ $this->error( "Image SHA-1 not known for {$row->img_name}." );
} else {
- $file = $repo->newFile( $row->img_name );
-
if ( $oldLayout === 'sha1' ) {
$spath = "{$origBase}/{$sha1[0]}/{$sha1[1]}/{$sha1[2]}/{$sha1}";
} else {
$dpath = $file->getPath();
}
- $status = $be->prepare( array( 'dir' => dirname( $dpath ) ) );
+ $status = $be->prepare( array(
+ 'dir' => dirname( $dpath ), 'bypassReadOnly' => 1 ) );
if ( !$status->isOK() ) {
$this->error( print_r( $status->getErrorsArray(), true ) );
}
$dpath = $ofile->getPath();
}
- $status = $be->prepare( array( 'dir' => dirname( $dpath ) ) );
+ $status = $be->prepare( array(
+ 'dir' => dirname( $dpath ), 'bypassReadOnly' => 1 ) );
if ( !$status->isOK() ) {
$this->error( print_r( $status->getErrorsArray(), true ) );
}
'/' . $repo->getDeletedHashPath( $sha1Key ) . $sha1Key;
}
- $status = $be->prepare( array( 'dir' => dirname( $dpath ) ) );
+ $status = $be->prepare( array(
+ 'dir' => dirname( $dpath ), 'bypassReadOnly' => 1 ) );
if ( !$status->isOK() ) {
$this->error( print_r( $status->getErrorsArray(), true ) );
}
$this->output( "\"{$op['img']}\" (dest: {$op['dst']})\n" );
}
- $status = $be->doOperations( $ops );
+ $status = $be->doOperations( $ops, array( 'bypassReadOnly' => 1 ) );
if ( !$status->isOK() ) {
$this->output( print_r( $status->getErrorsArray(), true ) );
}