diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-12-28 12:00:48 -0500 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-12-28 12:00:48 -0500 |
commit | ad902a9848a66135ae85a04b1c66b663219a53ea (patch) | |
tree | 30b54d57dd1ba3ead7049974909de746db6f19e4 /apps/files_external | |
parent | d9ff3b68602d511ede1fd8bf2516a842dee2cfd1 (diff) | |
download | nextcloud-server-ad902a9848a66135ae85a04b1c66b663219a53ea.tar.gz nextcloud-server-ad902a9848a66135ae85a04b1c66b663219a53ea.zip |
Move storage backend tests from constructor to test function
Diffstat (limited to 'apps/files_external')
-rw-r--r-- | apps/files_external/lib/amazons3.php | 12 | ||||
-rwxr-xr-x | apps/files_external/lib/config.php | 4 | ||||
-rwxr-xr-x | apps/files_external/lib/dropbox.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/ftp.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/google.php | 11 | ||||
-rw-r--r-- | apps/files_external/lib/smb.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/webdav.php | 4 |
7 files changed, 17 insertions, 26 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index c1b2e889bba..5ab89df732d 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -36,10 +36,6 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { if (isset($params['key']) && isset($params['secret']) && isset($params['bucket'])) { $this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret'])); $this->bucket = $params['bucket']; - $test = $this->s3->get_canonical_user_id(); - if (!isset($test['id']) || $test['id'] == '') { - throw new Exception(); - } } else { throw new Exception(); } @@ -250,4 +246,12 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { return $response->isOK(); } + public function test() { + $test = $this->s3->get_canonical_user_id(); + if (isset($test['id']) && $test['id'] != '') { + return true; + } + return false; + } + } diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 99d31c5aa2d..fd654f04e98 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -192,8 +192,8 @@ class OC_Mount_Config { } if (class_exists($class)) { try { - new $class($options); - return true; + $storage = new $class($options); + return $storage->test(); } catch (Exception $exception) { return false; } diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php index a4f3f678344..66dfd3e595e 100755 --- a/apps/files_external/lib/dropbox.php +++ b/apps/files_external/lib/dropbox.php @@ -41,10 +41,6 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_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'); - $test = $this->stat(''); - if (!$test) { - throw new Exception('Creating OC_Filestorage_Dropbox storage failed'); - } } else { throw new Exception('Creating OC_Filestorage_Dropbox storage failed'); } diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index ac487156c18..ca408d5d224 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -33,10 +33,6 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ if ( ! $this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } - $test = $this->stat(''); - if (!$test) { - throw new Exception(); - } //create the root folder if necesary if ( ! $this->is_dir('')) { $this->mkdir(''); diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 19772d4d37f..8710c979117 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -42,10 +42,6 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { $this->oauth_token = new OAuthToken($params['token'], $params['token_secret']); $this->sig_method = new OAuthSignatureMethod_HMAC_SHA1(); $this->entries = array(); - $test = $this->free_space(''); - if (!$test) { - throw new Exception(); - } } else { throw new Exception('Creating OC_Filestorage_Google storage failed'); } @@ -594,4 +590,11 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { } + public function test() { + if ($this->free_space('')) { + return true; + } + return false; + } + }
\ No newline at end of file diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 97454b46015..5b73e993e4f 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -34,10 +34,6 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ if (substr($this->share, -1, 1)=='/') { $this->share=substr($this->share, 0, -1); } - $test = $this->stat(''); - if (!$test) { - throw new Exception(); - } //create the root folder if necesary if ( ! $this->is_dir('')) { $this->mkdir(''); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index cfe073a1f1c..31d36f1e78b 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -60,10 +60,6 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $this->client->addTrustedCertificates($certPath); } } - $test = $this->stat(''); - if (!$test) { - throw new Exception(); - } //create the root folder if necesary $this->mkdir(''); } else { |