r68959 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68958‎ | r68959 | r68960 >
Date:18:27, 3 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Work on porting WP filesystem abstraction classes
Modified paths:
  • /trunk/extensions/Deployment/includes/Filesystem.php (modified) (history)
  • /trunk/extensions/Deployment/includes/filesystems/DirectFilesystem.php (modified) (history)
  • /trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php
@@ -204,7 +204,7 @@
205205 * @see Filesystem::doCopy
206206 */
207207 protected function doCopy( $from, $to ) {
208 - $content = $this->get_contents( $from );
 208+ $content = $this->getContents( $from );
209209
210210 if ( $content === false ) {
211211 return false;
@@ -216,8 +216,8 @@
217217 /**
218218 * @see Filesystem::doMove
219219 */
220 - protected function doMove( $from, $to ) {
221 -
 220+ protected function doMove( $from, $to, $overwrite ) {
 221+ return (bool)@ftp_rename( $this->connection, $from, $to );
222222 }
223223
224224 /**
Index: trunk/extensions/Deployment/includes/filesystems/DirectFilesystem.php
@@ -167,8 +167,18 @@
168168 /**
169169 * @see Filesystem::doMove
170170 */
171 - protected function doMove( $from, $to ) {
172 -
 171+ protected function doMove( $from, $to, $overwrite ) {
 172+ // try using rename first. if that fails (for example, source is read only) try copy and delete.
 173+ if ( @rename( $from, $to) ) {
 174+ return true;
 175+ }
 176+
 177+ if ( $this->copy( $from, $to, $overwrite ) && $this->exists( $to ) ) {
 178+ $this->delete( $from );
 179+ return true;
 180+ } else {
 181+ return false;
 182+ }
173183 }
174184
175185 /**
Index: trunk/extensions/Deployment/includes/Filesystem.php
@@ -268,7 +268,7 @@
269269 *
270270 * @return boolean Success indicator
271271 */
272 - protected abstract function doMove( $from, $to );
 272+ protected abstract function doMove( $from, $to, $overwrite );
273273
274274 /**
275275 * Constructor
@@ -303,7 +303,7 @@
304304 return false;
305305 }
306306
307 - return $this->doCopy();
 307+ return $this->doCopy( $from, $to );
308308 }
309309
310310 /**
@@ -320,7 +320,7 @@
321321 return false;
322322 }
323323
324 - return $this->doMove();
 324+ return $this->doMove( $from, $to, $overwrite );
325325 }
326326
327327 /**

Status & tagging log