summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/dropbox.php
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-14 10:20:00 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-14 10:22:13 -0400
commit4c7fd8cd0191871e48704f693f48554d4ee7a726 (patch)
treea66a930783de938deaa3d2362dcf779e5c2b45af /apps/files_external/lib/dropbox.php
parent64ef1e21819979d7fdc406d2628bc175b16fe554 (diff)
parent62e4f55f721971dacd06649cecefe0487626aa75 (diff)
downloadnextcloud-server-4c7fd8cd0191871e48704f693f48554d4ee7a726.tar.gz
nextcloud-server-4c7fd8cd0191871e48704f693f48554d4ee7a726.zip
Merge branch 'master' into share_api
Conflicts: lib/group.php lib/group/backend.php lib/group/database.php lib/group/interface.php lib/public/user.php lib/user.php lib/user/backend.php lib/user/database.php lib/user/interface.php
Diffstat (limited to 'apps/files_external/lib/dropbox.php')
-rwxr-xr-xapps/files_external/lib/dropbox.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 15446ff0bc3..b90563a5065 100755
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -30,9 +30,13 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
private static $tempFiles = array();
public function __construct($params) {
- $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');
+ if (isset($params['configured']) && $params['configured'] == 'true' && isset($params['app_key']) && isset($params['app_secret']) && isset($params['token']) && isset($params['token_secret'])) {
+ $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');
+ } else {
+ throw new Exception('Creating OC_Filestorage_Dropbox storage failed');
+ }
}
private function getMetaData($path, $list = false) {
@@ -43,6 +47,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$response = $this->dropbox->getMetaData($path);
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
if ($response && isset($response['contents'])) {
@@ -63,6 +68,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this->metaData[$path] = $response;
return $response;
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
}
@@ -74,6 +80,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this->dropbox->createFolder($path);
return true;
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
}
@@ -141,6 +148,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this->dropbox->delete($path);
return true;
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
}
@@ -150,6 +158,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this->dropbox->move($path1, $path2);
return true;
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
}
@@ -159,6 +168,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this->dropbox->copy($path1, $path2);
return true;
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
}
@@ -173,6 +183,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
file_put_contents($tmpFile, $data);
return fopen($tmpFile, 'r');
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
case 'w':
@@ -211,7 +222,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$this->dropbox->putFile(self::$tempFiles[$tmpFile], $handle);
unlink($tmpFile);
} catch (Exception $exception) {
-
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
}
}
}
@@ -230,6 +241,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$info = $this->dropbox->getAccountInfo();
return $info['quota_info']['quota'] - $info['quota_info']['normal'];
} catch (Exception $exception) {
+ OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
return false;
}
}