]> source.dussan.org Git - nextcloud-server.git/commitdiff
Dont task external storages with creating their own root
authorRobin Appelman <icewind@owncloud.com>
Fri, 26 Apr 2013 15:40:31 +0000 (17:40 +0200)
committerRobin Appelman <icewind@owncloud.com>
Fri, 26 Apr 2013 15:40:31 +0000 (17:40 +0200)
apps/files_external/lib/dropbox.php
apps/files_external/lib/ftp.php
apps/files_external/lib/sftp.php
apps/files_external/lib/smb.php
apps/files_external/lib/streamwrapper.php
apps/files_external/lib/webdav.php
apps/files_external/tests/ftp.php
apps/files_external/tests/sftp.php
apps/files_external/tests/smb.php
apps/files_external/tests/webdav.php

index cb04e557f8a6b2b3c01a26e0a32330bd3c04cd65..081c54788814788ba2d7cd63142dbb08ba103543 100755 (executable)
@@ -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');
                }
index 8a7375ebe38730a270ba74ea1f275543e100fffd..ca6c635eb2b802812e8a3ef43d5dca6538e3760c 100644 (file)
@@ -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);
index ede6c251fd9e18463590b04ff7ee72a725c5f536..4fd360964631d652372d454d2097700d2b68d6cf 100644 (file)
@@ -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() {
index 961efb1a50a43123a43d299296cbb30d305875c7..655c3c9a81653b1fafad3bee8c8e6ffb9d1e4129 100644 (file)
@@ -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
index 4685877f26b7ea0bb0d7266bfceb897afa08f809..09041f335b46517a6076edb15f2db942a53aa9fc 100644 (file)
@@ -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));
        }
 
index 3ba7c48cd5742adcabbb94bc831364ee4c2f2ae2..c2fe7c67b582e994f65e60215d797590327665a0 100644 (file)
@@ -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(){
index 923b5e39681bd144a4adb3952d94ee17a92a1276..e146725473ac2bfb3444090a03ebfde58db86836 100644 (file)
@@ -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() {
index 16964e208781c34b4d8ecce4d90230496b51c2fe..efea7f075ff20d48d19d4b49a5e68448a023d423 100644 (file)
@@ -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
+}
index be3ea5a8308baed4a36ecfd70dfce9a04f28ca2e..ca2a93c894449f5584be40d6b996cc339b3aec89 100644 (file)
@@ -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() {
index 1702898045e772f34da117641a5038a8264dc753..1f9b767eca69d24ca1fff865471972f7c6a79eb6 100644 (file)
@@ -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() {