diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-11-29 12:58:57 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-12-02 11:12:09 +0100 |
commit | 3b18c1bae4fd038c378010e76d4946313f23f2ef (patch) | |
tree | 494fe145fe218f901ae290b3fe1e2a11e894b34c /tests/lib/files/storage/storage.php | |
parent | e079d34f5af344e432f0d4aa7f128d02e69336f2 (diff) | |
download | nextcloud-server-3b18c1bae4fd038c378010e76d4946313f23f2ef.tar.gz nextcloud-server-3b18c1bae4fd038c378010e76d4946313f23f2ef.zip |
Fixed FTP and SMB to use rmdir() when deleting folders
Some storages need to use different calls for deleting files or folders,
usually unlink() and rmdir().
Fixes #4532 (SMB dir deletion)
Fixes #5941 (FTP dir deletion)
Note that the extra is_dir() should be fast because it's read from the
stat cache.
Backport of d69243e
Diffstat (limited to 'tests/lib/files/storage/storage.php')
-rw-r--r-- | tests/lib/files/storage/storage.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php index 4587a3b2d06..ea3ca7d19e0 100644 --- a/tests/lib/files/storage/storage.php +++ b/tests/lib/files/storage/storage.php @@ -286,4 +286,28 @@ abstract class Storage extends \PHPUnit_Framework_TestCase { $this->instance->touch('foo'); $this->assertTrue($this->instance->file_exists('foo')); } + + public function testRecursiveRmdir() { + $this->instance->mkdir('folder'); + $this->instance->mkdir('folder/bar'); + $this->instance->file_put_contents('folder/asd.txt', 'foobar'); + $this->instance->file_put_contents('folder/bar/foo.txt', 'asd'); + $this->assertTrue($this->instance->rmdir('folder')); + $this->assertFalse($this->instance->file_exists('folder/asd.txt')); + $this->assertFalse($this->instance->file_exists('folder/bar/foo.txt')); + $this->assertFalse($this->instance->file_exists('folder/bar')); + $this->assertFalse($this->instance->file_exists('folder')); + } + + public function testRecursiveUnlink() { + $this->instance->mkdir('folder'); + $this->instance->mkdir('folder/bar'); + $this->instance->file_put_contents('folder/asd.txt', 'foobar'); + $this->instance->file_put_contents('folder/bar/foo.txt', 'asd'); + $this->assertTrue($this->instance->unlink('folder')); + $this->assertFalse($this->instance->file_exists('folder/asd.txt')); + $this->assertFalse($this->instance->file_exists('folder/bar/foo.txt')); + $this->assertFalse($this->instance->file_exists('folder/bar')); + $this->assertFalse($this->instance->file_exists('folder')); + } } |