Index: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php |
— | — | @@ -425,8 +425,9 @@ |
426 | 426 | // Restore any file that was at the destination |
427 | 427 | if ( $this->tmpSourcePath !== null ) { |
428 | 428 | $params = array( |
429 | | - 'src' => $this->tmpSourcePath, |
430 | | - 'dst' => $this->params['src'] |
| 429 | + 'src' => $this->tmpSourcePath, |
| 430 | + 'dst' => $this->params['src'], |
| 431 | + 'overwriteDest' => true |
431 | 432 | ); |
432 | 433 | $status = $this->backend->store( $params ); |
433 | 434 | if ( !$status->isOK() ) { |
— | — | @@ -446,8 +447,9 @@ |
447 | 448 | // Restore any file that was at the destination |
448 | 449 | if ( $this->tmpDestFile ) { |
449 | 450 | $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 |
452 | 454 | ); |
453 | 455 | $status = $this->backend->store( $params ); |
454 | 456 | if ( !$status->isOK() ) { |
— | — | @@ -548,13 +550,8 @@ |
549 | 551 | protected function doRevert() { |
550 | 552 | $status = Status::newGood(); |
551 | 553 | 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() |
559 | 556 | $status->merge( $this->restoreDest() ); |
560 | 557 | } |
561 | 558 | return $status; |
— | — | @@ -613,13 +610,8 @@ |
614 | 611 | protected function doRevert() { |
615 | 612 | $status = Status::newGood(); |
616 | 613 | 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() |
624 | 616 | $status->merge( $this->restoreDest() ); |
625 | 617 | } |
626 | 618 | return $status; |
— | — | @@ -683,13 +675,8 @@ |
684 | 676 | protected function doRevert() { |
685 | 677 | $status = Status::newGood(); |
686 | 678 | 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() |
694 | 681 | $status->merge( $this->restoreDest() ); |
695 | 682 | } |
696 | 683 | return $status; |
— | — | @@ -848,15 +835,9 @@ |
849 | 836 | } |
850 | 837 | |
851 | 838 | 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(); |
861 | 842 | } |
862 | 843 | |
863 | 844 | protected function getSourceSha1Base36() { |
— | — | @@ -918,7 +899,7 @@ |
919 | 900 | } |
920 | 901 | |
921 | 902 | protected function doRevert() { |
922 | | - // Restore any source file |
| 903 | + // Restore any source file that we deleted |
923 | 904 | return $this->restoreSource(); |
924 | 905 | } |
925 | 906 | |