fix recursive copy and rename for mapped local storage backend
This commit is contained in:
parent
03ba497a8c
commit
c3c9612c99
|
@ -177,6 +177,12 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->is_dir($path2)) {
|
||||||
|
$this->rmdir($path2);
|
||||||
|
} else if ($this->is_file($path2)) {
|
||||||
|
$this->unlink($path2);
|
||||||
|
}
|
||||||
|
|
||||||
$physicPath1 = $this->buildPath($path1);
|
$physicPath1 = $this->buildPath($path1);
|
||||||
$physicPath2 = $this->buildPath($path2);
|
$physicPath2 = $this->buildPath($path2);
|
||||||
if($return=rename($physicPath1, $physicPath2)) {
|
if($return=rename($physicPath1, $physicPath2)) {
|
||||||
|
@ -187,19 +193,30 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
public function copy($path1, $path2) {
|
public function copy($path1, $path2) {
|
||||||
|
if ($this->is_dir($path1)) {
|
||||||
if ($this->is_dir($path2)) {
|
if ($this->is_dir($path2)) {
|
||||||
if(!$this->file_exists($path2)) {
|
$this->rmdir($path2);
|
||||||
|
} else if ($this->is_file($path2)) {
|
||||||
|
$this->unlink($path2);
|
||||||
|
}
|
||||||
|
$dir = $this->opendir($path1);
|
||||||
$this->mkdir($path2);
|
$this->mkdir($path2);
|
||||||
|
while ($file = readdir($dir)) {
|
||||||
|
if (($file != '.') && ($file != '..')) {
|
||||||
|
if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
$source=substr($path1, strrpos($path1, '/')+1);
|
|
||||||
$path2.=$source;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
closedir($dir);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
if ($return = copy($this->buildPath($path1), $this->buildPath($path2))) {
|
if ($return = copy($this->buildPath($path1), $this->buildPath($path2))) {
|
||||||
// mapper needs to create copies or all children
|
|
||||||
$this->copyMapping($path1, $path2);
|
$this->copyMapping($path1, $path2);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function fopen($path, $mode) {
|
public function fopen($path, $mode) {
|
||||||
if($return=fopen($this->buildPath($path), $mode)) {
|
if($return=fopen($this->buildPath($path), $mode)) {
|
||||||
switch($mode) {
|
switch($mode) {
|
||||||
|
|
Loading…
Reference in New Issue