fix recursive rename for local storage backend
This commit is contained in:
parent
e83b41493f
commit
38c1da0976
2 changed files with 20 additions and 2 deletions
|
@ -177,9 +177,11 @@ if (\OC_Util::runningOnWindows()) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($return = rename($this->datadir . $path1, $this->datadir . $path2)) {
|
||||
if ($this->is_dir($path2)) {
|
||||
$this->rmdir($path2);
|
||||
}
|
||||
return $return;
|
||||
|
||||
return rename($this->datadir . $path1, $this->datadir . $path2);
|
||||
}
|
||||
|
||||
public function copy($path1, $path2) {
|
||||
|
|
|
@ -385,4 +385,20 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
|
|||
$this->assertEquals('qwerty', $this->instance->file_get_contents('target/test2.txt'));
|
||||
$this->assertEquals('bar', $this->instance->file_get_contents('target/subfolder/test.txt'));
|
||||
}
|
||||
|
||||
public function testRenameOverWriteDirectory() {
|
||||
$this->instance->mkdir('source');
|
||||
$this->instance->file_put_contents('source/test1.txt', 'foo');
|
||||
|
||||
$this->instance->mkdir('target');
|
||||
$this->instance->file_put_contents('target/test1.txt', 'bar');
|
||||
$this->instance->file_put_contents('target/test2.txt', 'bar');
|
||||
|
||||
$this->instance->rename('source', 'target');
|
||||
|
||||
$this->assertFalse($this->instance->file_exists('source'));
|
||||
$this->assertFalse($this->instance->file_exists('source/test1.txt'));
|
||||
$this->assertFalse($this->instance->file_exists('target/test2.txt'));
|
||||
$this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue