summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/storage.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/lib/storage.php')
-rw-r--r--apps/files_trashbin/lib/storage.php35
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;