summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-04-26 17:40:31 +0200
committerRobin Appelman <icewind@owncloud.com>2013-04-26 17:40:31 +0200
commitc05195a46d60741ef8ee1db4afaee85ef7d1f70c (patch)
tree655a51d015ac4ba7e915daca7d0550a5942ed0ad /apps/files_external
parent8a838e0e03501fd0230ae1e843f53213331d2c55 (diff)
downloadnextcloud-server-c05195a46d60741ef8ee1db4afaee85ef7d1f70c.tar.gz
nextcloud-server-c05195a46d60741ef8ee1db4afaee85ef7d1f70c.zip
Dont task external storages with creating their own root
Diffstat (limited to 'apps/files_external')
-rwxr-xr-xapps/files_external/lib/dropbox.php1
-rw-r--r--apps/files_external/lib/ftp.php6
-rw-r--r--apps/files_external/lib/sftp.php4
-rw-r--r--apps/files_external/lib/smb.php1
-rw-r--r--apps/files_external/lib/streamwrapper.php36
-rw-r--r--apps/files_external/lib/webdav.php2
-rw-r--r--apps/files_external/tests/ftp.php1
-rw-r--r--apps/files_external/tests/sftp.php3
-rw-r--r--apps/files_external/tests/smb.php1
-rw-r--r--apps/files_external/tests/webdav.php1
10 files changed, 10 insertions, 46 deletions
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index cb04e557f8a..081c5478881 100755
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -45,7 +45,6 @@ class Dropbox extends \OC\Files\Storage\Common {
$oauth = new \Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
$oauth->setToken($params['token'], $params['token_secret']);
$this->dropbox = new \Dropbox_API($oauth, 'dropbox');
- $this->mkdir('');
} else {
throw new \Exception('Creating \OC\Files\Storage\Dropbox storage failed');
}
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index 8a7375ebe38..ca6c635eb2b 100644
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -35,10 +35,6 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
if ( ! $this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
- //create the root folder if necessary
- if ( ! $this->is_dir('')) {
- $this->mkdir('');
- }
} else {
throw new \Exception();
}
@@ -63,7 +59,6 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
return $url;
}
public function fopen($path,$mode) {
- $this->init();
switch($mode) {
case 'r':
case 'rb':
@@ -100,7 +95,6 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
}
public function writeBack($tmpFile) {
- $this->init();
if (isset(self::$tempFiles[$tmpFile])) {
$this->uploadFile($tmpFile, self::$tempFiles[$tmpFile]);
unlink($tmpFile);
diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php
index ede6c251fd9..4fd36096463 100644
--- a/apps/files_external/lib/sftp.php
+++ b/apps/files_external/lib/sftp.php
@@ -50,10 +50,6 @@ class SFTP extends \OC\Files\Storage\Common {
$host_keys[$this->host] = $current_host_key;
$this->write_host_keys($host_keys);
}
-
- if(!$this->file_exists('')){
- $this->mkdir('');
- }
}
public function test() {
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index 961efb1a50a..655c3c9a816 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -73,7 +73,6 @@ class SMB extends \OC\Files\Storage\StreamWrapper{
* @return bool
*/
public function hasUpdated($path,$time) {
- $this->init();
if(!$path and $this->root=='/') {
// mtime doesn't work for shares, but giving the nature of the backend,
// doing a full update is still just fast enough
diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php
index 4685877f26b..09041f335b4 100644
--- a/apps/files_external/lib/streamwrapper.php
+++ b/apps/files_external/lib/streamwrapper.php
@@ -8,46 +8,28 @@
namespace OC\Files\Storage;
-abstract class StreamWrapper extends \OC\Files\Storage\Common{
- private $ready = false;
-
- protected function init(){
- if($this->ready) {
- return;
- }
- $this->ready = true;
-
- //create the root folder if necesary
- if(!$this->is_dir('')) {
- $this->mkdir('');
- }
- }
-
+abstract class StreamWrapper extends Common{
abstract public function constructUrl($path);
public function mkdir($path) {
- $this->init();
return mkdir($this->constructUrl($path));
}
public function rmdir($path) {
- $this->init();
if($this->file_exists($path)) {
- $succes = rmdir($this->constructUrl($path));
+ $success = rmdir($this->constructUrl($path));
clearstatcache();
- return $succes;
+ return $success;
} else {
return false;
}
}
public function opendir($path) {
- $this->init();
return opendir($this->constructUrl($path));
}
public function filetype($path) {
- $this->init();
return filetype($this->constructUrl($path));
}
@@ -60,24 +42,20 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{
}
public function file_exists($path) {
- $this->init();
return file_exists($this->constructUrl($path));
}
public function unlink($path) {
- $this->init();
- $succes = unlink($this->constructUrl($path));
+ $success = unlink($this->constructUrl($path));
clearstatcache();
- return $succes;
+ return $success;
}
public function fopen($path, $mode) {
- $this->init();
return fopen($this->constructUrl($path), $mode);
}
public function touch($path, $mtime=null) {
- $this->init();
if(is_null($mtime)) {
$fh = $this->fopen($path, 'a');
fwrite($fh, '');
@@ -88,22 +66,18 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{
}
public function getFile($path, $target) {
- $this->init();
return copy($this->constructUrl($path), $target);
}
public function uploadFile($path, $target) {
- $this->init();
return copy($path, $this->constructUrl($target));
}
public function rename($path1, $path2) {
- $this->init();
return rename($this->constructUrl($path1), $this->constructUrl($path2));
}
public function stat($path) {
- $this->init();
return stat($this->constructUrl($path));
}
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 3ba7c48cd57..c2fe7c67b58 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -73,8 +73,6 @@ class DAV extends \OC\Files\Storage\Common{
$this->client->addTrustedCertificates($certPath);
}
}
- //create the root folder if necessary
- $this->mkdir('');
}
public function getId(){
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
index 923b5e39681..e146725473a 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -19,6 +19,7 @@ class FTP extends Storage {
}
$this->config['ftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
$this->instance = new \OC\Files\Storage\FTP($this->config['ftp']);
+ $this->instance->mkdir('/');
}
public function tearDown() {
diff --git a/apps/files_external/tests/sftp.php b/apps/files_external/tests/sftp.php
index 16964e20878..efea7f075ff 100644
--- a/apps/files_external/tests/sftp.php
+++ b/apps/files_external/tests/sftp.php
@@ -33,6 +33,7 @@ class SFTP extends Storage {
}
$this->config['sftp']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
$this->instance = new \OC\Files\Storage\SFTP($this->config['sftp']);
+ $this->instance->mkdir('/');
}
public function tearDown() {
@@ -40,4 +41,4 @@ class SFTP extends Storage {
$this->instance->rmdir('/');
}
}
-} \ No newline at end of file
+}
diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/smb.php
index be3ea5a8308..ca2a93c8944 100644
--- a/apps/files_external/tests/smb.php
+++ b/apps/files_external/tests/smb.php
@@ -20,6 +20,7 @@ class SMB extends Storage {
}
$this->config['smb']['root'] .= $id; //make sure we have an new empty folder to work in
$this->instance = new \OC\Files\Storage\SMB($this->config['smb']);
+ $this->instance->mkdir('/');
}
public function tearDown() {
diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/webdav.php
index 1702898045e..1f9b767eca6 100644
--- a/apps/files_external/tests/webdav.php
+++ b/apps/files_external/tests/webdav.php
@@ -20,6 +20,7 @@ class DAV extends Storage {
}
$this->config['webdav']['root'] .= '/' . $id; //make sure we have an new empty folder to work in
$this->instance = new \OC\Files\Storage\DAV($this->config['webdav']);
+ $this->instance->mkdir('/');
}
public function tearDown() {