diff options
author | Robin Appelman <robin@icewind.nl> | 2018-09-10 14:40:35 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-10-17 14:56:45 +0200 |
commit | 4adac445dc57d1ccc7f26e21018e1e731e5b1654 (patch) | |
tree | b3da061a9332a1ebca2809a61ea3cf186d9fb259 /apps/files_trashbin/lib/Sabre/TrashFolder.php | |
parent | 2634ceb35b72eac94e6bf4c61640036392c5f97f (diff) | |
download | nextcloud-server-4adac445dc57d1ccc7f26e21018e1e731e5b1654.tar.gz nextcloud-server-4adac445dc57d1ccc7f26e21018e1e731e5b1654.zip |
fix select statement
fix select statement
Make trashbin api modules
Apps can register trashbin backends for specific storages,
allowing them to modify trashbin behavior for storages
The old trashbin implementation has been wrapped in a "legacy" backend,
for future work this can be replaced with a new backend that better handles
shares while still keeping the legacy backend around to keep existing trash
from being accessible
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_trashbin/lib/Sabre/TrashFolder.php')
-rw-r--r-- | apps/files_trashbin/lib/Sabre/TrashFolder.php | 78 |
1 files changed, 1 insertions, 77 deletions
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']; - } } |