Browse Source

Merge pull request #17025 from owncloud/sftp-rmdir-emptydir

Workaround for empty dir deletion for SFTP
remotes/origin/poc-doctrine-migrations
Robin McCorkell 11 years ago
parent
commit
05fb9ceef9
  1. 6
      apps/files_external/lib/sftp.php
  2. 7
      tests/lib/files/storage/storage.php

6
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;
}

7
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');

Loading…
Cancel
Save