https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106675
Revision: 106675 Author: aaron Date: 2011-12-19 19:35:36 +0000 (Mon, 19 Dec 2011) Log Message: ----------- Simplified FileOp code by having restoreSource()/restoreDest() use 'overwriteDest' Modified Paths: -------------- branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php 2011-12-19 19:13:51 UTC (rev 106674) +++ branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php 2011-12-19 19:35:36 UTC (rev 106675) @@ -425,8 +425,9 @@ // Restore any file that was at the destination if ( $this->tmpSourcePath !== null ) { $params = array( - 'src' => $this->tmpSourcePath, - 'dst' => $this->params['src'] + 'src' => $this->tmpSourcePath, + 'dst' => $this->params['src'], + 'overwriteDest' => true ); $status = $this->backend->store( $params ); if ( !$status->isOK() ) { @@ -446,8 +447,9 @@ // Restore any file that was at the destination if ( $this->tmpDestFile ) { $params = array( - 'src' => $this->tmpDestFile->getPath(), - 'dst' => $this->params['dst'] + 'src' => $this->tmpDestFile->getPath(), + 'dst' => $this->params['dst'], + 'overwriteDest' => true ); $status = $this->backend->store( $params ); if ( !$status->isOK() ) { @@ -548,13 +550,8 @@ protected function doRevert() { $status = Status::newGood(); if ( !$this->destSameAsSource ) { - // Remove the file saved to the destination - $params = array( 'src' => $this->params['dst'] ); - $status->merge( $this->backend->delete( $params ) ); - if ( !$status->isOK() ) { - return $status; // also can't restore any dest file - } - // Restore any file that was at the destination + // Restore any file that was at the destination, + // overwritting what was put there in attempt() $status->merge( $this->restoreDest() ); } return $status; @@ -613,13 +610,8 @@ protected function doRevert() { $status = Status::newGood(); if ( !$this->destSameAsSource ) { - // Remove the file saved to the destination - $params = array( 'src' => $this->params['dst'] ); - $status->merge( $this->backend->delete( $params ) ); - if ( !$status->isOK() ) { - return $status; // also can't restore any dest file - } - // Restore any file that was at the destination + // Restore any file that was at the destination, + // overwritting what was put there in attempt() $status->merge( $this->restoreDest() ); } return $status; @@ -683,13 +675,8 @@ protected function doRevert() { $status = Status::newGood(); if ( !$this->destSameAsSource ) { - // Remove the file saved to the destination - $params = array( 'src' => $this->params['dst'] ); - $status->merge( $this->backend->delete( $params ) ); - if ( !$status->isOK() ) { - return $status; // also can't restore any dest file - } - // Restore any file that was at the destination + // Restore any file that was at the destination, + // overwritting what was put there in attempt() $status->merge( $this->restoreDest() ); } return $status; @@ -848,15 +835,9 @@ } protected function doRevert() { - // Remove the file saved to the destination - $params = array( 'src' => $this->params['dst'] ); - $status = $this->backend->delete( $params ); - if ( !$status->isOK() ) { - return $status; // also can't restore any dest file - } - // Restore any file that was at the destination - $status->merge( $this->restoreDest() ); - return $status; + // Restore any file that was at the destination, + // overwritting what was put there in attempt() + return $this->restoreDest(); } protected function getSourceSha1Base36() { @@ -918,7 +899,7 @@ } protected function doRevert() { - // Restore any source file + // Restore any source file that we deleted return $this->restoreSource(); } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs