r69364 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69363‎ | r69364 | r69365 >
Date:00:22, 15 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Work on porting WP filesystem abstraction classes
Modified paths:
  • /trunk/extensions/Deployment/includes/filesystems/Ssh2Filesystem.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Deployment/includes/filesystems/Ssh2Filesystem.php
@@ -314,14 +314,14 @@
315315 * @see Filesystem::isDir
316316 */
317317 public function isDir( $path ) {
318 - return is_dir( 'ssh2.sftp://' . $this->sftpConnection . '/' . ltrim( $file, '/' ) );
 318+ return is_dir( 'ssh2.sftp://' . $this->sftpConnection . '/' . ltrim( $path, '/' ) );
319319 }
320320
321321 /**
322322 * @see Filesystem::isFile
323323 */
324324 public function isFile( $path ) {
325 - return is_file( 'ssh2.sftp://' . $this->sftpConnection . '/' . ltrim( $file, '/' ) );
 325+ return is_file( 'ssh2.sftp://' . $this->sftpConnection . '/' . ltrim( $path, '/' ) );
326326 }
327327
328328 /**
@@ -349,21 +349,44 @@
350350 * @see Filesystem::makeDir
351351 */
352352 public function makeDir( $path, $chmod = false, $chown = false, $chgrp = false ) {
 353+ $path = rtrim( $path, '/' );
353354
 355+ if ( !$chmod ) {
 356+ $chmod = FS_CHMOD_DIR;
 357+ }
 358+
 359+ if ( !ssh2_sftp_mkdir( $this->sftpConnection, $path, $chmod, true ) ) {
 360+ return false;
 361+ }
 362+
 363+ if ( $chown ) {
 364+ $this->chown( $path, $chown );
 365+ }
 366+
 367+ if ( $chgrp ) {
 368+ $this->chgrp( $path, $chgrp );
 369+ }
 370+
 371+ return true;
354372 }
355373
356374 /**
357375 * @see Filesystem::touch
358376 */
359377 public function touch( $file, $time = 0, $atime = 0 ) {
360 -
 378+ return false;
361379 }
362380
363381 /**
364382 * @see Filesystem::writeToFile
365383 */
366384 public function writeToFile( $file, $contents ) {
367 -
 385+ $file = ltrim( $file, '/' );
 386+ $ret = file_put_contents( 'ssh2.sftp://' . $this->sftpConnection . '/' . $file, $contents );
 387+
 388+ $this->chmod( $file );
 389+
 390+ return $ret !== false;
368391 }
369392
370393 protected function runCommandRecursivly( $command, $file, $recursive, $mode = false ) {
@@ -372,10 +395,10 @@
373396 }
374397
375398 if ( !$mode ) {
376 - if ( $this->is_file($file) ) {
 399+ if ( $this->isFile( $file ) ) {
377400 $mode = FS_CHMOD_FILE;
378401 }
379 - elseif ( $this->is_dir($file) ) {
 402+ elseif ( $this->isDir( $file ) ) {
380403 $mode = FS_CHMOD_DIR;
381404 }
382405 else {

Status & tagging log