|
|
@ -28,6 +28,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ |
|
|
|
private $rootContainer; |
|
|
|
private $rootContainer; |
|
|
|
|
|
|
|
|
|
|
|
private static $tempFiles=array(); |
|
|
|
private static $tempFiles=array(); |
|
|
|
|
|
|
|
private $objects=array(); |
|
|
|
|
|
|
|
private $containers=array(); |
|
|
|
|
|
|
|
|
|
|
|
const SUBCONTAINER_FILE='.subcontainers'; |
|
|
|
const SUBCONTAINER_FILE='.subcontainers'; |
|
|
|
|
|
|
|
|
|
|
@ -38,7 +40,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private function getContainerName($path){ |
|
|
|
private function getContainerName($path){ |
|
|
|
$path=trim($this->root.$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=='/'){ |
|
|
|
if($path=='' or $path=='/'){ |
|
|
|
return $this->rootContainer; |
|
|
|
return $this->rootContainer; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(isset($this->containers[$path])){ |
|
|
|
|
|
|
|
return $this->containers[$path]; |
|
|
|
|
|
|
|
} |
|
|
|
try{ |
|
|
|
try{ |
|
|
|
$container=$this->conn->get_container($this->getContainerName($path)); |
|
|
|
$container=$this->conn->get_container($this->getContainerName($path)); |
|
|
|
|
|
|
|
$this->containers[$path]=$container; |
|
|
|
return $container; |
|
|
|
return $container; |
|
|
|
}catch(NoSuchContainerException $e){ |
|
|
|
}catch(NoSuchContainerException $e){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -87,12 +93,16 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ |
|
|
|
* @return CF_Object |
|
|
|
* @return CF_Object |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private function getObject($path){ |
|
|
|
private function getObject($path){ |
|
|
|
|
|
|
|
if(isset($this->objects[$path])){ |
|
|
|
|
|
|
|
return $this->objects[$path]; |
|
|
|
|
|
|
|
} |
|
|
|
$container=$this->getContainer(dirname($path)); |
|
|
|
$container=$this->getContainer(dirname($path)); |
|
|
|
if(is_null($container)){ |
|
|
|
if(is_null($container)){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
try{ |
|
|
|
try{ |
|
|
|
$obj=$container->get_object(basename($path)); |
|
|
|
$obj=$container->get_object(basename($path)); |
|
|
|
|
|
|
|
$this->objects[$path]=$obj; |
|
|
|
return $obj; |
|
|
|
return $obj; |
|
|
|
}catch(NoSuchObjectException $e){ |
|
|
|
}catch(NoSuchObjectException $e){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -295,6 +305,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->conn->delete_container($this->getContainerName($path)); |
|
|
|
$this->conn->delete_container($this->getContainerName($path)); |
|
|
|
|
|
|
|
unset($this->containers[$path]); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -309,12 +320,14 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ |
|
|
|
if($sub){ |
|
|
|
if($sub){ |
|
|
|
$this->emptyContainer($path.'/'.$sub); |
|
|
|
$this->emptyContainer($path.'/'.$sub); |
|
|
|
$this->conn->delete_container($this->getContainerName($path.'/'.$sub)); |
|
|
|
$this->conn->delete_container($this->getContainerName($path.'/'.$sub)); |
|
|
|
|
|
|
|
unset($this->containers[$path.'/'.$sub]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$objects=$this->getObjects($container); |
|
|
|
$objects=$this->getObjects($container); |
|
|
|
foreach($objects as $object){ |
|
|
|
foreach($objects as $object){ |
|
|
|
$container->delete_object($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)){ |
|
|
|
if($this->objectExists($path)){ |
|
|
|
$container=$this->getContainer(dirname($path)); |
|
|
|
$container=$this->getContainer(dirname($path)); |
|
|
|
$container->delete_object(basename($path)); |
|
|
|
$container->delete_object(basename($path)); |
|
|
|
|
|
|
|
unset($this->objects[$path]); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -447,6 +461,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ |
|
|
|
$sourceContainer=$this->getContainer(dirname($path1)); |
|
|
|
$sourceContainer=$this->getContainer(dirname($path1)); |
|
|
|
$targetContainer=$this->getContainer(dirname($path2)); |
|
|
|
$targetContainer=$this->getContainer(dirname($path2)); |
|
|
|
$result=$sourceContainer->move_object_to(basename($path1),$targetContainer,basename($path2)); |
|
|
|
$result=$sourceContainer->move_object_to(basename($path1),$targetContainer,basename($path2)); |
|
|
|
|
|
|
|
unset($this->objects[$path1]); |
|
|
|
if($result){ |
|
|
|
if($result){ |
|
|
|
$targetObj=$this->getObject($path2); |
|
|
|
$targetObj=$this->getObject($path2); |
|
|
|
$this->resetMTime($targetObj); |
|
|
|
$this->resetMTime($targetObj); |
|
|
|