[Pkg-owncloud-commits] [owncloud] 93/199: fix recursive rename for local storage backend
David Prévot
taffit at moszumanska.debian.org
Sun Jun 1 18:53:13 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 38c1da09768d034ee788f0c6a4284591e914fe4a
Author: Robin Appelman <icewind at owncloud.com>
Date: Mon Jul 1 17:45:01 2013 +0200
fix recursive rename for local storage backend
---
lib/private/files/storage/local.php | 6 ++++--
tests/lib/files/storage/storage.php | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index aaa9f3c..ec28eba 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -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) {
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index 92afd47..4a4626f 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -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'));
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list