summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-10-19 20:49:54 +0200
committerVincent Petry <pvince81@owncloud.com>2015-10-19 20:52:15 +0200
commitd795643ef906eaf1268450fcd7a9b2ea128806c6 (patch)
tree2ba319f9e146f5f650bf2f0d4641615ef24cc6f8 /apps/files_external
parent90e34e26bd94527f55a7e941519b07396e5052d1 (diff)
downloadnextcloud-server-d795643ef906eaf1268450fcd7a9b2ea128806c6.tar.gz
nextcloud-server-d795643ef906eaf1268450fcd7a9b2ea128806c6.zip
Fix Dropbox metadata cache with trimmed paths
Makes sure that the paths are trimmed to avoid duplicate entries like "/test" and "test". This should make this storage slightly faster by reducing the cache misses.
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/dropbox.php14
1 files changed, 9 insertions, 5 deletions
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 4ab14d4f3e0..8eea8d9f75b 100644
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -64,7 +64,7 @@ class Dropbox extends \OC\Files\Storage\Common {
* @param string $path
*/
private function deleteMetaData($path) {
- $path = $this->root.$path;
+ $path = ltrim($this->root.$path, '/');
if (isset($this->metaData[$path])) {
unset($this->metaData[$path]);
return true;
@@ -72,6 +72,10 @@ class Dropbox extends \OC\Files\Storage\Common {
return false;
}
+ private function setMetaData($path, $metaData) {
+ $this->metaData[ltrim($path, '/')] = $metaData;
+ }
+
/**
* Returns the path's metadata
* @param string $path path for which to return the metadata
@@ -80,7 +84,7 @@ class Dropbox extends \OC\Files\Storage\Common {
* false, null if the file doesn't exist or "false" if the operation failed
*/
private function getDropBoxMetaData($path, $list = false) {
- $path = $this->root.$path;
+ $path = ltrim($this->root.$path, '/');
if ( ! $list && isset($this->metaData[$path])) {
return $this->metaData[$path];
} else {
@@ -96,14 +100,14 @@ class Dropbox extends \OC\Files\Storage\Common {
// Cache folder's contents
foreach ($response['contents'] as $file) {
if (!isset($file['is_deleted']) || !$file['is_deleted']) {
- $this->metaData[$path.'/'.basename($file['path'])] = $file;
+ $this->setMetaData($path.'/'.basename($file['path']), $file);
$contents[] = $file;
}
}
unset($response['contents']);
}
if (!isset($response['is_deleted']) || !$response['is_deleted']) {
- $this->metaData[$path] = $response;
+ $this->setMetaData($path, $response);
}
// Return contents of folder only
return $contents;
@@ -116,7 +120,7 @@ class Dropbox extends \OC\Files\Storage\Common {
$response = $this->dropbox->getMetaData($requestPath, 'false');
if (!isset($response['is_deleted']) || !$response['is_deleted']) {
- $this->metaData[$path] = $response;
+ $this->setMetaData($path, $response);
return $response;
}
return null;