Skip to content

Commit 4174ce6

Browse files
artongebackportbot[bot]
authored andcommitted
feat: Support X-NC-Skip-Trashbin header
This is useful for clients that want to directly and permanently delete a file. Signed-off-by: Louis Chemineau <louis@chmn.me> [skip ci]
1 parent 29533a6 commit 4174ce6

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

apps/files_trashbin/lib/Storage.php

+7-13
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
use OC\Files\Storage\Wrapper\Wrapper;
1111
use OCA\Files_Trashbin\Events\MoveToTrashEvent;
1212
use OCA\Files_Trashbin\Trash\ITrashManager;
13+
use OCP\App\IAppManager;
1314
use OCP\Encryption\Exceptions\GenericEncryptionException;
1415
use OCP\EventDispatcher\IEventDispatcher;
1516
use OCP\Files\IRootFolder;
1617
use OCP\Files\Node;
1718
use OCP\Files\Storage\IStorage;
19+
use OCP\IRequest;
1820
use OCP\IUserManager;
21+
use OCP\Server;
1922
use Psr\Log\LoggerInterface;
2023

2124
class Storage extends Wrapper {
@@ -159,18 +162,7 @@ private function doDelete($path, $method) {
159162
return call_user_func([$this->storage, $method], $path);
160163
}
161164

162-
// check permissions before we continue, this is especially important for
163-
// shared files
164-
if (!$this->isDeletable($path)) {
165-
return false;
166-
}
167-
168-
$isMovedToTrash = $this->trashManager->moveToTrash($this, $path);
169-
if (!$isMovedToTrash) {
170-
return call_user_func([$this->storage, $method], $path);
171-
} else {
172-
return true;
173-
}
165+
return call_user_func([$this->storage, $method], $path);
174166
}
175167

176168
/**
@@ -182,16 +174,18 @@ public static function setupStorage() {
182174
$logger = \OC::$server->get(LoggerInterface::class);
183175
$eventDispatcher = \OC::$server->get(IEventDispatcher::class);
184176
$rootFolder = \OC::$server->get(IRootFolder::class);
177+
$request = \OC::$server->get(IRequest::class);
185178
Filesystem::addStorageWrapper(
186179
'oc_trashbin',
187-
function (string $mountPoint, IStorage $storage) use ($trashManager, $userManager, $logger, $eventDispatcher, $rootFolder) {
180+
function (string $mountPoint, IStorage $storage) use ($trashManager, $userManager, $logger, $eventDispatcher, $rootFolder, $request) {
188181
return new Storage(
189182
['storage' => $storage, 'mountPoint' => $mountPoint],
190183
$trashManager,
191184
$userManager,
192185
$logger,
193186
$eventDispatcher,
194187
$rootFolder,
188+
$request,
195189
);
196190
},
197191
1);

0 commit comments

Comments
 (0)