[Pkg-owncloud-commits] [owncloud] 36/205: Workaround for empty dir deletion for SFTP

David Prévot taffit at moszumanska.debian.org
Thu Jul 2 17:36:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit e15dd783ab86c0c65ec626685d59fff0128f3aca
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Jun 18 17:40:38 2015 +0200

    Workaround for empty dir deletion for SFTP
    
    Explicitly clear the stat cache after deleting an empty folder to make
    sure it is properly detected as deleted in subsequent requests.
    
    This works around a problem with phpseclib where the folder is properly
    deleted remotely but the stat cache was not updated.
---
 apps/files_external/lib/sftp.php    | 6 +++++-
 tests/lib/files/storage/storage.php | 7 +++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php
index c457a87..cbe0903 100644
--- a/apps/files_external/lib/sftp.php
+++ b/apps/files_external/lib/sftp.php
@@ -251,7 +251,11 @@ class SFTP extends \OC\Files\Storage\Common {
 	 */
 	public function rmdir($path) {
 		try {
-			return $this->getConnection()->delete($this->absPath($path), true);
+			$result = $this->getConnection()->delete($this->absPath($path), true);
+			// workaround: stray stat cache entry when deleting empty folders
+			// see https://github.com/phpseclib/phpseclib/issues/706
+			$this->getConnection()->clearStatCache();
+			return $result;
 		} catch (\Exception $e) {
 			return false;
 		}
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index 2355009..fcd7f73 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -380,6 +380,13 @@ abstract class Storage extends \Test\TestCase {
 		$this->assertFalse($this->instance->file_exists('folder'));
 	}
 
+	public function testRmdirEmptyFolder() {
+		$this->assertTrue($this->instance->mkdir('empty'));
+		$this->wait();
+		$this->assertTrue($this->instance->rmdir('empty'));
+		$this->assertFalse($this->instance->file_exists('empty'));
+	}
+
 	public function testRecursiveUnlink() {
 		$this->instance->mkdir('folder');
 		$this->instance->mkdir('folder/bar');

-- 
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