Skip to content

Commit

Permalink
Merge pull request #1 from sunweaver/pr/various-ssh2-fixes
Browse files Browse the repository at this point in the history
Horde_Vfs: Various SSH2 driver fixes
  • Loading branch information
mrubinsk committed Oct 3, 2020
2 parents f88615f + d47025c commit 08b96b1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/Horde/Vfs/Ssh2.php
Expand Up @@ -101,7 +101,7 @@ public function size($path, $name)
$this->_connect();

$statinfo = @ssh2_sftp_stat($this->_sftp, $this->_getPath($path, $name));
if (($size = $statinfo['size']) === false) {
if ( ($statinfo === false) or (($size = $statinfo['size']) === false) ) {
throw new Horde_Vfs_Exception(sprintf('Unable to check file size of "%s".', $this->_getPath($path, $name)));
}

Expand Down Expand Up @@ -260,7 +260,7 @@ public function isFolder($path, $name)
/* See if we can stat the remote filename. ANDed with 040000 is true
* if it is a directory. */
$statinfo = @ssh2_sftp_stat($this->_sftp, $this->_getPath($path, $name));
return $statinfo['mode'] & 040000;
return ( $statinfo !== false ) and ( $statinfo['mode'] & 040000 );
}

/**
Expand Down Expand Up @@ -865,12 +865,8 @@ protected function _recv($remote, $local)
*/
protected function _wrap($remote)
{
$wrapper = 'ssh2.sftp://' . $this->_params['username'] . ':'
. $this->_params['password'] . '@' . $this->_params['hostspec'];
if (!empty($this->_params['port'])) {
$wrapper .= ':' . $this->_params['port'];
}
if ($remote{0} != '/') {
$wrapper = 'ssh2.sftp://' . intval($this->_sftp);
if ($remote[0] != '/') {
$remote = $this->getCurrentDirectory() . '/' . $remote;
}
return $wrapper . $remote;
Expand Down

0 comments on commit 08b96b1

Please sign in to comment.