fix recursive copy and rename for common storage backend
This commit is contained in:
parent
c3c9612c99
commit
ea44f0e20f
|
@ -137,21 +137,50 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
|||
}
|
||||
|
||||
public function rename($path1, $path2) {
|
||||
if ($this->copy($path1, $path2)) {
|
||||
if ($this->file_exists($path2)) {
|
||||
if ($this->is_dir($path2)) {
|
||||
$this->rmdir($path2);
|
||||
} else if ($this->is_file($path2)) {
|
||||
$this->unlink($path2);
|
||||
}
|
||||
}
|
||||
|
||||
$this->removeCachedFile($path1);
|
||||
return $this->unlink($path1);
|
||||
if ($this->is_dir($path1)) {
|
||||
return $this->copy($path1, $path2) and $this->rmdir($path1);
|
||||
} else {
|
||||
return false;
|
||||
return $this->copy($path1, $path2) and $this->unlink($path1);
|
||||
}
|
||||
}
|
||||
|
||||
public function copy($path1, $path2) {
|
||||
if ($this->is_dir($path1)) {
|
||||
if ($this->file_exists($path2)) {
|
||||
if ($this->is_dir($path2)) {
|
||||
$this->rmdir($path2);
|
||||
} else if ($this->is_file($path2)) {
|
||||
$this->unlink($path2);
|
||||
}
|
||||
}
|
||||
$dir = $this->opendir($path1);
|
||||
$this->mkdir($path2);
|
||||
while ($file = readdir($dir)) {
|
||||
if (($file != '.') && ($file != '..')) {
|
||||
if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
return true;
|
||||
} else {
|
||||
$source = $this->fopen($path1, 'r');
|
||||
$target = $this->fopen($path2, 'w');
|
||||
list($count, $result) = \OC_Helper::streamCopy($source, $target);
|
||||
list(, $result) = \OC_Helper::streamCopy($source, $target);
|
||||
$this->removeCachedFile($path2);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMimeType($path) {
|
||||
if ($this->is_dir($path)) {
|
||||
|
|
Loading…
Reference in New Issue