diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-05-11 17:53:21 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-05-12 11:09:02 +0200 |
commit | beb6a38d8519ab75109e95e1ae33e5f212a8f9bf (patch) | |
tree | b5c7a77ed735a9b65cf497607e83607ae8bf50f5 /apps/files_trashbin/lib | |
parent | 20d2d8d3ddee2750343bdec69a3e7031b710039a (diff) | |
download | nextcloud-server-beb6a38d8519ab75109e95e1ae33e5f212a8f9bf.tar.gz nextcloud-server-beb6a38d8519ab75109e95e1ae33e5f212a8f9bf.zip |
Added rmdir to trashbin storage wrapper
This makes sure that folders are moved to trash when deleted with
rmdir() instead of unlink().
This happens for example when deleting a folder over WebDAV.
The web UI uses unlink() so it wasn't affected.
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r-- | apps/files_trashbin/lib/storage.php | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/apps/files_trashbin/lib/storage.php b/apps/files_trashbin/lib/storage.php index 418d7d2f1fd..006971fb242 100644 --- a/apps/files_trashbin/lib/storage.php +++ b/apps/files_trashbin/lib/storage.php @@ -81,14 +81,39 @@ class Storage extends Wrapper { /** * Deletes the given file by moving it into the trashbin. * - * @param string $path + * @param string $path path of file or folder to delete + * + * @return bool true if the operation succeeded, false otherwise */ public function unlink($path) { + return $this->doDelete($path, 'unlink'); + } + + /** + * Deletes the given folder by moving it into the trashbin. + * + * @param string $path path of folder to delete + * + * @return bool true if the operation succeeded, false otherwise + */ + public function rmdir($path) { + return $this->doDelete($path, 'rmdir'); + } + + /** + * Run the delete operation with the given method + * + * @param string $path path of file or folder to delete + * @param string $method either "unlink" or "rmdir" + * + * @return bool true if the operation succeeded, false otherwise + */ + private function doDelete($path, $method) { if (self::$disableTrash || !\OC_App::isEnabled('files_trashbin') || (pathinfo($path, PATHINFO_EXTENSION) === 'part') ) { - return $this->storage->unlink($path); + return call_user_func_array([$this->storage, $method], [$path]); } $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path); $result = true; @@ -101,14 +126,14 @@ class Storage extends Wrapper { // in cross-storage cases the file will be copied // but not deleted, so we delete it here if ($result) { - $this->storage->unlink($path); + call_user_func_array([$this->storage, $method], [$path]); } } else { - $result = $this->storage->unlink($path); + $result = call_user_func_array([$this->storage, $method], [$path]); } unset($this->deletedFiles[$normalized]); } else if ($this->storage->file_exists($path)) { - $result = $this->storage->unlink($path); + $result = call_user_func_array([$this->storage, $method], [$path]); } return $result; |