summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/Sabre
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/lib/Sabre')
-rw-r--r--apps/files_trashbin/lib/Sabre/AbstractTrash.php27
-rw-r--r--apps/files_trashbin/lib/Sabre/AbstractTrashFile.php36
-rw-r--r--apps/files_trashbin/lib/Sabre/AbstractTrashFolder.php77
-rw-r--r--apps/files_trashbin/lib/Sabre/RestoreFolder.php8
-rw-r--r--apps/files_trashbin/lib/Sabre/RootCollection.php15
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashFile.php37
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashFolder.php78
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashFolderFile.php44
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashFolderFolder.php91
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashHome.php30
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashRoot.php57
11 files changed, 205 insertions, 295 deletions
diff --git a/apps/files_trashbin/lib/Sabre/AbstractTrash.php b/apps/files_trashbin/lib/Sabre/AbstractTrash.php
index 43f9cc02749..b4d13a41e38 100644
--- a/apps/files_trashbin/lib/Sabre/AbstractTrash.php
+++ b/apps/files_trashbin/lib/Sabre/AbstractTrash.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
@@ -21,13 +22,20 @@
namespace OCA\Files_Trashbin\Sabre;
+use OCA\Files_Trashbin\Trash\ITrashItem;
+use OCA\Files_Trashbin\Trash\ITrashManager;
use OCP\Files\FileInfo;
+use OCP\IUser;
abstract class AbstractTrash implements ITrash {
- /** @var FileInfo */
+ /** @var ITrashItem */
protected $data;
- public function __construct(FileInfo $data) {
+ /** @var ITrashManager */
+ protected $trashManager;
+
+ public function __construct(ITrashManager $trashManager, ITrashItem $data) {
+ $this->trashManager = $trashManager;
$this->data = $data;
}
@@ -36,7 +44,7 @@ abstract class AbstractTrash implements ITrash {
}
public function getDeletionTime(): int {
- return $this->data->getMtime();
+ return $this->data->getDeletedTime();
}
public function getFileId(): int {
@@ -66,4 +74,17 @@ abstract class AbstractTrash implements ITrash {
public function getName(): string {
return $this->data->getName();
}
+
+ public function getOriginalLocation(): string {
+ return $this->data->getOriginalLocation();
+ }
+
+ public function delete() {
+ $this->trashManager->removeItem($this->data);
+ }
+
+ public function restore(): bool {
+ $this->trashManager->restoreItem($this->data);
+ return true;
+ }
}
diff --git a/apps/files_trashbin/lib/Sabre/AbstractTrashFile.php b/apps/files_trashbin/lib/Sabre/AbstractTrashFile.php
new file mode 100644
index 00000000000..da7c94eb35d
--- /dev/null
+++ b/apps/files_trashbin/lib/Sabre/AbstractTrashFile.php
@@ -0,0 +1,36 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files_Trashbin\Sabre;
+
+use Sabre\DAV\Exception\Forbidden;
+use Sabre\DAV\IFile;
+
+abstract class AbstractTrashFile extends AbstractTrash implements IFile , ITrash{
+ public function put($data) {
+ throw new Forbidden();
+ }
+
+ public function setName($name) {
+ throw new Forbidden();
+ }
+}
diff --git a/apps/files_trashbin/lib/Sabre/AbstractTrashFolder.php b/apps/files_trashbin/lib/Sabre/AbstractTrashFolder.php
new file mode 100644
index 00000000000..dd45dbd5c8c
--- /dev/null
+++ b/apps/files_trashbin/lib/Sabre/AbstractTrashFolder.php
@@ -0,0 +1,77 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files_Trashbin\Sabre;
+
+use OCA\Files_Trashbin\Trash\ITrashItem;
+use OCP\Files\FileInfo;
+use Sabre\DAV\Exception\Forbidden;
+use Sabre\DAV\Exception\NotFound;
+use Sabre\DAV\ICollection;
+
+abstract class AbstractTrashFolder extends AbstractTrash implements ICollection, ITrash {
+ public function getChildren(): array {
+ $entries = $this->trashManager->listTrashFolder($this->data);
+
+ $children = array_map(function (ITrashItem $entry) {
+ if ($entry->getType() === FileInfo::TYPE_FOLDER) {
+ return new TrashFolderFolder($this->trashManager, $entry);
+ }
+ return new TrashFolderFile($this->trashManager, $entry);
+ }, $entries);
+
+ return $children;
+ }
+
+ public function getChild($name): ITrash {
+ $entries = $this->getChildren();
+
+ foreach ($entries as $entry) {
+ if ($entry->getName() === $name) {
+ return $entry;
+ }
+ }
+
+ throw new NotFound();
+ }
+
+ public function childExists($name): bool {
+ try {
+ $this->getChild($name);
+ return true;
+ } catch (NotFound $e) {
+ return false;
+ }
+ }
+
+ public function setName($name) {
+ throw new Forbidden();
+ }
+
+ public function createFile($name, $data = null) {
+ throw new Forbidden();
+ }
+
+ public function createDirectory($name) {
+ throw new Forbidden();
+ }
+}
diff --git a/apps/files_trashbin/lib/Sabre/RestoreFolder.php b/apps/files_trashbin/lib/Sabre/RestoreFolder.php
index 04f23db0ed4..177064dbb48 100644
--- a/apps/files_trashbin/lib/Sabre/RestoreFolder.php
+++ b/apps/files_trashbin/lib/Sabre/RestoreFolder.php
@@ -31,14 +31,6 @@ use Sabre\DAV\INode;
class RestoreFolder implements ICollection, IMoveTarget {
-
- /** @var string */
- protected $userId;
-
- public function __construct(string $userId) {
- $this->userId = $userId;
- }
-
public function createFile($name, $data = null) {
throw new Forbidden();
}
diff --git a/apps/files_trashbin/lib/Sabre/RootCollection.php b/apps/files_trashbin/lib/Sabre/RootCollection.php
index be31d200f71..0b55953aa3f 100644
--- a/apps/files_trashbin/lib/Sabre/RootCollection.php
+++ b/apps/files_trashbin/lib/Sabre/RootCollection.php
@@ -21,18 +21,27 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
namespace OCA\Files_Trashbin\Sabre;
+use OCA\Files_Trashbin\Trash\ITrashManager;
use OCP\IConfig;
use Sabre\DAV\INode;
use Sabre\DAVACL\AbstractPrincipalCollection;
use Sabre\DAVACL\PrincipalBackend;
class RootCollection extends AbstractPrincipalCollection {
+ /** @var ITrashManager */
+ private $trashManager;
- public function __construct(PrincipalBackend\BackendInterface $principalBackend, IConfig $config) {
+ public function __construct(
+ ITrashManager $trashManager,
+ PrincipalBackend\BackendInterface $principalBackend,
+ IConfig $config
+ ) {
parent::__construct($principalBackend, 'principals/users');
+ $this->trashManager = $trashManager;
$this->disableListing = !$config->getSystemValue('debug', false);
}
@@ -47,12 +56,12 @@ class RootCollection extends AbstractPrincipalCollection {
* @return INode
*/
public function getChildForPrincipal(array $principalInfo): TrashHome {
- list(,$name) = \Sabre\Uri\split($principalInfo['uri']);
+ list(, $name) = \Sabre\Uri\split($principalInfo['uri']);
$user = \OC::$server->getUserSession()->getUser();
if (is_null($user) || $name !== $user->getUID()) {
throw new \Sabre\DAV\Exception\Forbidden();
}
- return new TrashHome($principalInfo);
+ return new TrashHome($principalInfo, $this->trashManager, $user);
}
public function getName(): string {
diff --git a/apps/files_trashbin/lib/Sabre/TrashFile.php b/apps/files_trashbin/lib/Sabre/TrashFile.php
index 840ca6a1938..dd6500e5b81 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFile.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFile.php
@@ -21,46 +21,15 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-namespace OCA\Files_Trashbin\Sabre;
-
-use OCP\Files\FileInfo;
-use Sabre\DAV\Exception\Forbidden;
-use Sabre\DAV\IFile;
-
-class TrashFile extends AbstractTrash implements IFile, ITrash {
- /** @var string */
- private $userId;
-
- public function __construct(string $userId, FileInfo $data) {
- $this->userId = $userId;
- parent::__construct($data);
- }
- public function put($data) {
- throw new Forbidden();
- }
+namespace OCA\Files_Trashbin\Sabre;
+class TrashFile extends AbstractTrashFile {
public function get() {
- return $this->data->getStorage()->fopen($this->data->getInternalPath().'.d'.$this->getLastModified(), 'rb');
- }
-
- public function delete() {
- \OCA\Files_Trashbin\Trashbin::delete($this->data->getName(), $this->userId, $this->getLastModified());
+ return $this->data->getStorage()->fopen($this->data->getInternalPath() . '.d' . $this->getLastModified(), 'rb');
}
public function getName(): string {
return $this->data->getName() . '.d' . $this->getLastModified();
}
-
- public function setName($name) {
- throw new Forbidden();
- }
-
- public function restore(): bool {
- return \OCA\Files_Trashbin\Trashbin::restore($this->getName(), $this->data->getName(), $this->getLastModified());
- }
-
- public function getOriginalLocation(): string {
- return $this->data['extraData'];
- }
}
diff --git a/apps/files_trashbin/lib/Sabre/TrashFolder.php b/apps/files_trashbin/lib/Sabre/TrashFolder.php
index d884eefcc9f..108aaf4f312 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFolder.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFolder.php
@@ -23,85 +23,9 @@ declare(strict_types=1);
*/
namespace OCA\Files_Trashbin\Sabre;
-use OCP\Files\FileInfo;
-use Sabre\DAV\Exception\Forbidden;
-use Sabre\DAV\Exception\NotFound;
-use Sabre\DAV\ICollection;
-
-class TrashFolder extends AbstractTrash implements ICollection, ITrash {
- /** @var string */
- private $userId;
-
- public function __construct(string $root, string $userId, FileInfo $data) {
- $this->userId = $userId;
- parent::__construct($data);
- }
-
- public function createFile($name, $data = null) {
- throw new Forbidden();
- }
-
- public function createDirectory($name) {
- throw new Forbidden();
- }
-
- public function getChild($name): ITrash {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId);
-
- foreach ($entries as $entry) {
- if ($entry->getName() === $name) {
- if ($entry->getType() === FileInfo::TYPE_FOLDER) {
- return new TrashFolderFolder($this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }
- return new TrashFolderFile($this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }
- }
-
- throw new NotFound();
- }
-
- public function getChildren(): array {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId);
-
- $children = array_map(function (FileInfo $entry) {
- if ($entry->getType() === FileInfo::TYPE_FOLDER) {
- return new TrashFolderFolder($this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }
- return new TrashFolderFile($this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }, $entries);
-
- return $children;
- }
-
- public function childExists($name): bool {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId);
-
- foreach ($entries as $entry) {
- if ($entry->getName() === $name) {
- return true;
- }
- }
-
- return false;
- }
-
- public function delete() {
- \OCA\Files_Trashbin\Trashbin::delete($this->data->getName(), $this->userId, $this->getLastModified());
- }
+class TrashFolder extends AbstractTrashFolder {
public function getName(): string {
return $this->data->getName() . '.d' . $this->getLastModified();
}
-
- public function setName($name) {
- throw new Forbidden();
- }
-
- public function restore(): bool {
- return \OCA\Files_Trashbin\Trashbin::restore($this->getName(), $this->data->getName(), $this->getLastModified());
- }
-
- public function getOriginalLocation(): string {
- return $this->data['extraData'];
- }
}
diff --git a/apps/files_trashbin/lib/Sabre/TrashFolderFile.php b/apps/files_trashbin/lib/Sabre/TrashFolderFile.php
index 3e28d048b42..31ee9535b72 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFolderFile.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFolderFile.php
@@ -23,51 +23,9 @@ declare(strict_types=1);
*/
namespace OCA\Files_Trashbin\Sabre;
-use OCP\Files\FileInfo;
-use Sabre\DAV\Exception\Forbidden;
-use Sabre\DAV\IFile;
-
-class TrashFolderFile extends AbstractTrash implements IFile, ITrash {
- /** @var string */
- private $root;
-
- /** @var string */
- private $userId;
-
- /** @var string */
- private $location;
-
- public function __construct(string $root,
- string $userId,
- FileInfo $data,
- string $location) {
- $this->root = $root;
- $this->userId = $userId;
- $this->location = $location;
- parent::__construct($data);
- }
-
- public function put($data) {
- throw new Forbidden();
- }
+class TrashFolderFile extends AbstractTrashFile {
public function get() {
return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb');
}
-
- public function delete() {
- \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null);
- }
-
- public function setName($name) {
- throw new Forbidden();
- }
-
- public function restore(): bool {
- return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null);
- }
-
- public function getOriginalLocation(): string {
- return $this->location . '/' . $this->getFilename();
- }
}
diff --git a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php
index 4ee9a0e2db0..5332b7dd4c0 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php
@@ -21,95 +21,8 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-namespace OCA\Files_Trashbin\Sabre;
-
-use OCP\Files\FileInfo;
-use Sabre\DAV\Exception\Forbidden;
-use Sabre\DAV\Exception\NotFound;
-use Sabre\DAV\ICollection;
-
-class TrashFolderFolder extends AbstractTrash implements ICollection, ITrash {
-
- /** @var string */
- private $root;
-
- /** @var string */
- private $userId;
-
- /** @var string */
- private $location;
-
- public function __construct(string $root,
- string $userId,
- FileInfo $data,
- string $location) {
- $this->root = $root;
- $this->userId = $userId;
- $this->location = $location;
- parent::__construct($data);
- }
-
- public function createFile($name, $data = null) {
- throw new Forbidden();
- }
-
- public function createDirectory($name) {
- throw new Forbidden();
- }
-
- public function getChild($name): ITrash {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId);
-
- foreach ($entries as $entry) {
- if ($entry->getName() === $name) {
- if ($entry->getType() === FileInfo::TYPE_FOLDER) {
- return new TrashFolderFolder($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }
- return new TrashFolderFile($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }
- }
- throw new NotFound();
- }
-
- public function getChildren(): array {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId);
-
- $children = array_map(function (FileInfo $entry) {
- if ($entry->getType() === FileInfo::TYPE_FOLDER) {
- return new TrashFolderFolder($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }
- return new TrashFolderFile($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation());
- }, $entries);
-
- return $children;
- }
-
- public function childExists($name): bool {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId);
-
- foreach ($entries as $entry) {
- if ($entry->getName() === $name) {
- return true;
- }
- }
-
- return false;
- }
-
- public function delete() {
- \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null);
- }
-
- public function setName($name) {
- throw new Forbidden();
- }
-
- public function restore(): bool {
- return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null);
- }
+namespace OCA\Files_Trashbin\Sabre;
- public function getOriginalLocation(): string {
- return $this->location . '/' . $this->getFilename();
- }
+class TrashFolderFolder extends AbstractTrashFolder {
}
diff --git a/apps/files_trashbin/lib/Sabre/TrashHome.php b/apps/files_trashbin/lib/Sabre/TrashHome.php
index d1c50c9c6a3..12c2578bc3b 100644
--- a/apps/files_trashbin/lib/Sabre/TrashHome.php
+++ b/apps/files_trashbin/lib/Sabre/TrashHome.php
@@ -21,19 +21,33 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
namespace OCA\Files_Trashbin\Sabre;
+use OCA\Files_Trashbin\Trash\ITrashManager;
+use OCP\IUser;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\ICollection;
class TrashHome implements ICollection {
+ /** @var ITrashManager */
+ private $trashManager;
/** @var array */
private $principalInfo;
- public function __construct(array $principalInfo) {
+ /** @var IUser */
+ private $user;
+
+ public function __construct(
+ array $principalInfo,
+ ITrashManager $trashManager,
+ IUser $user
+ ) {
$this->principalInfo = $principalInfo;
+ $this->trashManager = $trashManager;
+ $this->user = $user;
}
public function delete() {
@@ -41,7 +55,7 @@ class TrashHome implements ICollection {
}
public function getName(): string {
- list(,$name) = \Sabre\Uri\split($this->principalInfo['uri']);
+ list(, $name) = \Sabre\Uri\split($this->principalInfo['uri']);
return $name;
}
@@ -58,24 +72,20 @@ class TrashHome implements ICollection {
}
public function getChild($name) {
- list(,$userId) = \Sabre\Uri\split($this->principalInfo['uri']);
-
if ($name === 'restore') {
- return new RestoreFolder($userId);
+ return new RestoreFolder();
}
if ($name === 'trash') {
- return new TrashRoot($userId);
+ return new TrashRoot($this->user, $this->trashManager);
}
throw new NotFound();
}
public function getChildren(): array {
- list(,$userId) = \Sabre\Uri\split($this->principalInfo['uri']);
-
return [
- new RestoreFolder($userId),
- new TrashRoot($userId),
+ new RestoreFolder(),
+ new TrashRoot($this->user, $this->trashManager)
];
}
diff --git a/apps/files_trashbin/lib/Sabre/TrashRoot.php b/apps/files_trashbin/lib/Sabre/TrashRoot.php
index 73b9d44d7e1..45f27f48b17 100644
--- a/apps/files_trashbin/lib/Sabre/TrashRoot.php
+++ b/apps/files_trashbin/lib/Sabre/TrashRoot.php
@@ -23,18 +23,25 @@ declare(strict_types=1);
*/
namespace OCA\Files_Trashbin\Sabre;
+use OCA\Files_Trashbin\Trash\ITrashItem;
+use OCA\Files_Trashbin\Trash\ITrashManager;
use OCP\Files\FileInfo;
+use OCP\IUser;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\ICollection;
class TrashRoot implements ICollection {
- /** @var string */
- private $userId;
+ /** @var IUser */
+ private $user;
- public function __construct(string $userId) {
- $this->userId = $userId;
+ /** @var ITrashManager */
+ private $trashManager;
+
+ public function __construct(IUser $user, ITrashManager $trashManager) {
+ $this->user = $user;
+ $this->trashManager = $trashManager;
}
public function delete() {
@@ -57,44 +64,38 @@ class TrashRoot implements ICollection {
throw new Forbidden('Not allowed to create folders in the trashbin');
}
- public function getChild($name): ITrash {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles('/', $this->userId);
-
- foreach ($entries as $entry) {
- if ($entry->getName() . '.d'.$entry->getMtime() === $name) {
- if ($entry->getType() === FileInfo::TYPE_FOLDER) {
- return new TrashFolder('/', $this->userId, $entry);
- }
- return new TrashFile($this->userId, $entry);
- }
- }
-
- throw new NotFound();
- }
-
public function getChildren(): array {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles('/', $this->userId);
+ $entries = $this->trashManager->listTrashRoot($this->user);
- $children = array_map(function (FileInfo $entry) {
+ $children = array_map(function (ITrashItem $entry) {
if ($entry->getType() === FileInfo::TYPE_FOLDER) {
- return new TrashFolder('/', $this->userId, $entry);
+ return new TrashFolder($this->trashManager, $entry);
}
- return new TrashFile($this->userId, $entry);
+ return new TrashFile($this->trashManager, $entry);
}, $entries);
return $children;
}
- public function childExists($name): bool {
- $entries = \OCA\Files_Trashbin\Helper::getTrashFiles('/', $this->userId);
+ public function getChild($name): ITrash {
+ $entries = $this->getChildren();
foreach ($entries as $entry) {
- if ($entry->getName() . '.d'.$entry->getMtime() === $name) {
- return true;
+ if ($entry->getName() === $name) {
+ return $entry;
}
}
- return false;
+ throw new NotFound();
+ }
+
+ public function childExists($name): bool {
+ try {
+ $this->getChild($name);
+ return true;
+ } catch (NotFound $e) {
+ return false;
+ }
}
public function getLastModified(): int {