summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/swift.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-04-25 00:11:10 +0200
committerRobin Appelman <icewind@owncloud.com>2012-04-25 00:12:12 +0200
commit5b70e2fb25a3228d46eb7ceaa497b957f8755d1e (patch)
treecfcc91d1a32a9cbbdb966f14bdf628b8e3a2a961 /apps/files_external/lib/swift.php
parent5c3ea148197c20b9754a539261d4b0fa1540a3c7 (diff)
downloadnextcloud-server-5b70e2fb25a3228d46eb7ceaa497b957f8755d1e.tar.gz
nextcloud-server-5b70e2fb25a3228d46eb7ceaa497b957f8755d1e.zip
some performance improvements to the openstack swift backend
Diffstat (limited to 'apps/files_external/lib/swift.php')
-rw-r--r--apps/files_external/lib/swift.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index e53eb1ff3b6..a987d17d799 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -28,6 +28,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
private $rootContainer;
private static $tempFiles=array();
+ private $objects=array();
+ private $containers=array();
const SUBCONTAINER_FILE='.subcontainers';
@@ -38,7 +40,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
*/
private function getContainerName($path){
$path=trim($this->root.$path,'/');
- return md5($path);
+ return str_replace('/','\\',$path);
}
/**
@@ -50,8 +52,12 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
if($path=='' or $path=='/'){
return $this->rootContainer;
}
+ if(isset($this->containers[$path])){
+ return $this->containers[$path];
+ }
try{
$container=$this->conn->get_container($this->getContainerName($path));
+ $this->containers[$path]=$container;
return $container;
}catch(NoSuchContainerException $e){
return null;
@@ -87,12 +93,16 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
* @return CF_Object
*/
private function getObject($path){
+ if(isset($this->objects[$path])){
+ return $this->objects[$path];
+ }
$container=$this->getContainer(dirname($path));
if(is_null($container)){
return null;
}else{
try{
$obj=$container->get_object(basename($path));
+ $this->objects[$path]=$obj;
return $obj;
}catch(NoSuchObjectException $e){
return null;
@@ -295,6 +305,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
}
$this->conn->delete_container($this->getContainerName($path));
+ unset($this->containers[$path]);
return true;
}
}
@@ -309,12 +320,14 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
if($sub){
$this->emptyContainer($path.'/'.$sub);
$this->conn->delete_container($this->getContainerName($path.'/'.$sub));
+ unset($this->containers[$path.'/'.$sub]);
}
}
$objects=$this->getObjects($container);
foreach($objects as $object){
$container->delete_object($object);
+ unset($this->objects[$path.'/'.$object]);
}
}
@@ -381,6 +394,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
if($this->objectExists($path)){
$container=$this->getContainer(dirname($path));
$container->delete_object(basename($path));
+ unset($this->objects[$path]);
}else{
return false;
}
@@ -447,6 +461,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
$sourceContainer=$this->getContainer(dirname($path1));
$targetContainer=$this->getContainer(dirname($path2));
$result=$sourceContainer->move_object_to(basename($path1),$targetContainer,basename($path2));
+ unset($this->objects[$path1]);
if($result){
$targetObj=$this->getObject($path2);
$this->resetMTime($targetObj);