r106675 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106674‎ | r106675 | r106676 >
Date:19:35, 19 December 2011
Author:aaron
Status:deferred
Tags:
Comment:
Simplified FileOp code by having restoreSource()/restoreDest() use 'overwriteDest'
Modified paths:
  • /branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php (modified) (history)

Diff [purge]

Index: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php
@@ -425,8 +425,9 @@
426426 // Restore any file that was at the destination
427427 if ( $this->tmpSourcePath !== null ) {
428428 $params = array(
429 - 'src' => $this->tmpSourcePath,
430 - 'dst' => $this->params['src']
 429+ 'src' => $this->tmpSourcePath,
 430+ 'dst' => $this->params['src'],
 431+ 'overwriteDest' => true
431432 );
432433 $status = $this->backend->store( $params );
433434 if ( !$status->isOK() ) {
@@ -446,8 +447,9 @@
447448 // Restore any file that was at the destination
448449 if ( $this->tmpDestFile ) {
449450 $params = array(
450 - 'src' => $this->tmpDestFile->getPath(),
451 - 'dst' => $this->params['dst']
 451+ 'src' => $this->tmpDestFile->getPath(),
 452+ 'dst' => $this->params['dst'],
 453+ 'overwriteDest' => true
452454 );
453455 $status = $this->backend->store( $params );
454456 if ( !$status->isOK() ) {
@@ -548,13 +550,8 @@
549551 protected function doRevert() {
550552 $status = Status::newGood();
551553 if ( !$this->destSameAsSource ) {
552 - // Remove the file saved to the destination
553 - $params = array( 'src' => $this->params['dst'] );
554 - $status->merge( $this->backend->delete( $params ) );
555 - if ( !$status->isOK() ) {
556 - return $status; // also can't restore any dest file
557 - }
558 - // Restore any file that was at the destination
 554+ // Restore any file that was at the destination,
 555+ // overwritting what was put there in attempt()
559556 $status->merge( $this->restoreDest() );
560557 }
561558 return $status;
@@ -613,13 +610,8 @@
614611 protected function doRevert() {
615612 $status = Status::newGood();
616613 if ( !$this->destSameAsSource ) {
617 - // Remove the file saved to the destination
618 - $params = array( 'src' => $this->params['dst'] );
619 - $status->merge( $this->backend->delete( $params ) );
620 - if ( !$status->isOK() ) {
621 - return $status; // also can't restore any dest file
622 - }
623 - // Restore any file that was at the destination
 614+ // Restore any file that was at the destination,
 615+ // overwritting what was put there in attempt()
624616 $status->merge( $this->restoreDest() );
625617 }
626618 return $status;
@@ -683,13 +675,8 @@
684676 protected function doRevert() {
685677 $status = Status::newGood();
686678 if ( !$this->destSameAsSource ) {
687 - // Remove the file saved to the destination
688 - $params = array( 'src' => $this->params['dst'] );
689 - $status->merge( $this->backend->delete( $params ) );
690 - if ( !$status->isOK() ) {
691 - return $status; // also can't restore any dest file
692 - }
693 - // Restore any file that was at the destination
 679+ // Restore any file that was at the destination,
 680+ // overwritting what was put there in attempt()
694681 $status->merge( $this->restoreDest() );
695682 }
696683 return $status;
@@ -848,15 +835,9 @@
849836 }
850837
851838 protected function doRevert() {
852 - // Remove the file saved to the destination
853 - $params = array( 'src' => $this->params['dst'] );
854 - $status = $this->backend->delete( $params );
855 - if ( !$status->isOK() ) {
856 - return $status; // also can't restore any dest file
857 - }
858 - // Restore any file that was at the destination
859 - $status->merge( $this->restoreDest() );
860 - return $status;
 839+ // Restore any file that was at the destination,
 840+ // overwritting what was put there in attempt()
 841+ return $this->restoreDest();
861842 }
862843
863844 protected function getSourceSha1Base36() {
@@ -918,7 +899,7 @@
919900 }
920901
921902 protected function doRevert() {
922 - // Restore any source file
 903+ // Restore any source file that we deleted
923904 return $this->restoreSource();
924905 }
925906

Status & tagging log