diff options
Diffstat (limited to 'apps/files_external/lib/sftp.php')
-rw-r--r-- | apps/files_external/lib/sftp.php | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 95e0cefa398..cd8a0e78864 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -10,6 +10,7 @@ namespace OC\Files\Storage; set_include_path(get_include_path() . PATH_SEPARATOR . \OC_App::getAppPath('files_external') . '/3rdparty/phpseclib/phpseclib'); require 'Net/SFTP.php'; +require 'Net/SFTP/Stream.php'; class SFTP extends \OC\Files\Storage\Common { private $host; @@ -205,16 +206,6 @@ class SFTP extends \OC\Files\Storage\Common { if ( !$this->file_exists($path)) { return false; } - - if (strrpos($path, '.')!==false) { - $ext=substr($path, strrpos($path, '.')); - } else { - $ext=''; - } - $tmp = \OC_Helper::tmpFile($ext); - $this->getFile($absPath, $tmp); - return fopen($tmp, $mode); - case 'w': case 'wb': case 'a': @@ -227,38 +218,14 @@ class SFTP extends \OC\Files\Storage\Common { case 'x+': case 'c': case 'c+': - if (strrpos($path, '.')!==false) { - $ext=substr($path, strrpos($path, '.')); - } else { - $ext=''; - } - - $tmpFile=\OC_Helper::tmpFile($ext); - \OC\Files\Stream\Close::registerCallback( - $tmpFile, - array($this, 'writeBack') - ); - - if ($this->file_exists($path)) { - $this->getFile($absPath, $tmpFile); - } - - self::$tempFiles[$tmpFile]=$absPath; - return fopen('close://'.$tmpFile, $mode); + // FIXME: make client login lazy to prevent it when using fopen() + return fopen($this->constructUrl($path), $mode); } } catch (\Exception $e) { } return false; } - public function writeBack($tmpFile) { - if (array_key_exists($tmpFile, self::$tempFiles)) { - $this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]); - unlink($tmpFile); - unset(self::$tempFiles[$tmpFile]); - } - } - public function touch($path, $mtime=null) { try { if (!is_null($mtime)) { @@ -309,4 +276,9 @@ class SFTP extends \OC\Files\Storage\Common { return false; } } + + public function constructUrl($path) { + $url = 'sftp://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path; + return $url; + } } |