diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-11-29 11:23:02 -0800 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-11-29 11:23:02 -0800 |
commit | baa587fd3cc77a6b52327dd75ceeaffe092826de (patch) | |
tree | 0468b5d01a397dfd7ba573686f6582cfa7264654 /apps | |
parent | 338a55e36cf8507156cc4d943cd301ec0361c930 (diff) | |
parent | d69243ee5144afeed57f513b0b50f9f2dbcdd36a (diff) | |
download | nextcloud-server-baa587fd3cc77a6b52327dd75ceeaffe092826de.tar.gz nextcloud-server-baa587fd3cc77a6b52327dd75ceeaffe092826de.zip |
Merge pull request #6123 from owncloud/extstorage-deletedirs2
Fixed FTP and SMB to use rmdir() when deleting folders
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/lib/ftp.php | 16 | ||||
-rw-r--r-- | apps/files_external/lib/smb.php | 12 | ||||
-rw-r--r-- | apps/files_external/lib/streamwrapper.php | 12 |
3 files changed, 33 insertions, 7 deletions
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index 1f3ebd14b39..00bf7a189ce 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -61,6 +61,22 @@ class FTP extends \OC\Files\Storage\StreamWrapper{ $url.='://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path; return $url; } + + /** + * Unlinks file or directory + * @param string @path + */ + public function unlink($path) { + if ($this->is_dir($path)) { + return $this->rmdir($path); + } + else { + $url = $this->constructUrl($path); + $result = unlink($url); + clearstatcache(true, $url); + return $result; + } + } public function fopen($path,$mode) { switch($mode) { case 'r': diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 5bff597fdca..c5fba92ee68 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -82,12 +82,18 @@ class SMB extends \OC\Files\Storage\StreamWrapper{ } /** - * Unlinks file + * Unlinks file or directory * @param string @path */ public function unlink($path) { - unlink($this->constructUrl($path)); - clearstatcache(); + if ($this->is_dir($path)) { + $this->rmdir($path); + } + else { + $url = $this->constructUrl($path); + unlink($url); + clearstatcache(false, $url); + } // smb4php still returns false even on success so // check here whether file was really deleted return !file_exists($path); diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index 7a1991d4f04..e484325e2fb 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -25,8 +25,9 @@ abstract class StreamWrapper extends Common { $this->unlink($path . '/' . $file); } } - $success = rmdir($this->constructUrl($path)); - clearstatcache(); + $url = $this->constructUrl($path); + $success = rmdir($url); + clearstatcache(false, $url); return $success; } else { return false; @@ -46,8 +47,11 @@ abstract class StreamWrapper extends Common { } public function unlink($path) { - $success = unlink($this->constructUrl($path)); - clearstatcache(); + $url = $this->constructUrl($path); + $success = unlink($url); + // normally unlink() is supposed to do this implicitly, + // but doing it anyway just to be sure + clearstatcache(false, $url); return $success; } |