[Pkg-owncloud-commits] [owncloud] 16/83: Fixed SMB file deletion success detection
David Prévot
taffit at moszumanska.debian.org
Wed Dec 18 13:05:25 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch 5.0
in repository owncloud.
commit 79929fb6fae506276e957f289a8c58640ed7ff1d
Author: Vincent Petry <pvince81 at owncloud.com>
Date: Thu Nov 14 18:39:39 2013 +0100
Fixed SMB file deletion success detection
Since unlink() smb4php doesn't return true on deletion success, we need
to check whether the file was deleted to confirm success.
Fixes #5866
Backport of eefd91355d54b7e49dd328cef9a9561ee51b0194
---
apps/files_external/lib/smb.php | 12 ++++++++++++
tests/lib/files/storage/storage.php | 16 ++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index 0168fa3..fb62599 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -72,6 +72,18 @@ class SMB extends \OC\Files\Storage\StreamWrapper{
}
/**
+ * Unlinks file
+ * @param string @path
+ */
+ public function unlink($path) {
+ unlink($this->constructUrl($path));
+ clearstatcache();
+ // smb4php still returns false even on success so
+ // check here whether file was really deleted
+ return !file_exists($path);
+ }
+
+ /**
* check if a file or folder has been updated since $time
* @param string $path
* @param int $time
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index 4089853..4587a3b 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -182,8 +182,9 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$this->assertTrue($this->instance->hasUpdated('/lorem.txt', $ctimeStart - 1));
$this->assertTrue($this->instance->hasUpdated('/', $ctimeStart - 1));
- $this->assertTrue(($ctimeStart - 1) <= $mTime);
- $this->assertTrue($mTime <= ($ctimeEnd + 1));
+ // check that ($ctimeStart - 1) <= $mTime <= ($ctimeEnd + 1)
+ $this->assertGreaterThanOrEqual(($ctimeStart - 1), $mTime);
+ $this->assertLessThanOrEqual(($ctimeEnd + 1), $mTime);
$this->assertEquals(filesize($textFile), $this->instance->filesize('/lorem.txt'));
$stat = $this->instance->stat('/lorem.txt');
@@ -249,6 +250,17 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$this->assertContains('/sub/logo-wide.png', $result);
}
+ public function testUnlink() {
+ $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
+ $this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile));
+
+ $this->assertTrue($this->instance->file_exists('/lorem.txt'));
+
+ $this->assertTrue($this->instance->unlink('/lorem.txt'));
+
+ $this->assertFalse($this->instance->file_exists('/lorem.txt'));
+ }
+
public function testFOpen() {
$textFile = \OC::$SERVERROOT . '/tests/data/lorem.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