summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/dropbox.php
diff options
context:
space:
mode:
authorHenrik Kjölhede <hkjolhede@gmail.com>2013-02-09 14:05:33 +0100
committerHenrik Kjölhede <hkjolhede@gmail.com>2013-02-09 14:05:33 +0100
commit41fa65e7befb249e260f2dd91e33971261cfd302 (patch)
tree4ebb4cb10f7869ba3288308ca3a35ce53970ed40 /apps/files_external/lib/dropbox.php
parentb1b2eafa50db54b2613cf2bc52bfab2015d67b2f (diff)
parentec829bd345045df985f623fa2fe6587d0ce68eb2 (diff)
downloadnextcloud-server-41fa65e7befb249e260f2dd91e33971261cfd302.tar.gz
nextcloud-server-41fa65e7befb249e260f2dd91e33971261cfd302.zip
Merge branch 'master' of https://github.com/owncloud/core
Conflicts: apps/files_external/appinfo/app.php
Diffstat (limited to 'apps/files_external/lib/dropbox.php')
-rwxr-xr-xapps/files_external/lib/dropbox.php61
1 files changed, 34 insertions, 27 deletions
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 33ca14cab15..11644e4a2c8 100755
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -20,12 +20,15 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+namespace OC\Files\Storage;
+
require_once 'Dropbox/autoload.php';
-class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
+class Dropbox extends \OC\Files\Storage\Common {
private $dropbox;
private $root;
+ private $id;
private $metaData = array();
private static $tempFiles = array();
@@ -37,13 +40,14 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
&& isset($params['token'])
&& isset($params['token_secret'])
) {
+ $this->id = 'dropbox::'.$params['app_key'] . $params['token']. '/' . $params['root'];
$this->root=isset($params['root'])?$params['root']:'';
- $oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_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');
+ $this->dropbox = new \Dropbox_API($oauth, 'dropbox');
$this->mkdir('');
} else {
- throw new Exception('Creating OC_Filestorage_Dropbox storage failed');
+ throw new \Exception('Creating \OC\Files\Storage\Dropbox storage failed');
}
}
@@ -55,8 +59,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
if ($list) {
try {
$response = $this->dropbox->getMetaData($path);
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
if ($response && isset($response['contents'])) {
@@ -76,21 +80,25 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$response = $this->dropbox->getMetaData($path, 'false');
$this->metaData[$path] = $response;
return $response;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
}
}
+ public function getId(){
+ return $this->id;
+ }
+
public function mkdir($path) {
$path = $this->root.$path;
try {
$this->dropbox->createFolder($path);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -106,7 +114,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
foreach ($contents as $file) {
$files[] = basename($file['path']);
}
- OC_FakeDirStream::$dirs['dropbox'.$path] = $files;
+ \OC\Files\Stream\Dir::register('dropbox'.$path, $files);
return opendir('fakedir://dropbox'.$path);
}
return false;
@@ -118,7 +126,6 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
$stat['size'] = $metaData['bytes'];
$stat['atime'] = time();
$stat['mtime'] = (isset($metaData['modified'])) ? strtotime($metaData['modified']) : time();
- $stat['ctime'] = $stat['mtime'];
return $stat;
}
return false;
@@ -163,8 +170,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->delete($path);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -175,8 +182,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->move($path1, $path2);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -187,8 +194,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->copy($path1, $path2);
return true;
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}
@@ -198,13 +205,13 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
switch ($mode) {
case 'r':
case 'rb':
- $tmpFile = OC_Helper::tmpFile();
+ $tmpFile = \OC_Helper::tmpFile();
try {
$data = $this->dropbox->getFile($path);
file_put_contents($tmpFile, $data);
return fopen($tmpFile, 'r');
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
case 'w':
@@ -224,8 +231,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
} else {
$ext = '';
}
- $tmpFile = OC_Helper::tmpFile($ext);
- OC_CloseStreamWrapper::$callBacks[$tmpFile] = array($this, 'writeBack');
+ $tmpFile = \OC_Helper::tmpFile($ext);
+ \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');
file_put_contents($tmpFile, $source);
@@ -242,8 +249,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$this->dropbox->putFile(self::$tempFiles[$tmpFile], $handle);
unlink($tmpFile);
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_external', $exception->getMessage(), OCP\Util::ERROR);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
}
}
}
@@ -264,8 +271,8 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
try {
$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);
+ } catch (\Exception $exception) {
+ \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
return false;
}
}