aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2019-09-06 17:46:03 +0200
committerGitHub <noreply@github.com>2019-09-06 17:46:03 +0200
commit8c77d3bfb640a98e84d320a02d53c8934f9a6a7b (patch)
treeb375d31a922318b5768b20120412d93a260f1bb6 /apps/files_trashbin
parent803c8ddf7f1b47aa99937455ba2c023c9d88c9db (diff)
parent8e7c287e2ac4bd60d69a77fb7295e8ea2b8b9617 (diff)
downloadnextcloud-server-8c77d3bfb640a98e84d320a02d53c8934f9a6a7b.tar.gz
nextcloud-server-8c77d3bfb640a98e84d320a02d53c8934f9a6a7b.zip
Merge pull request #16664 from nextcloud/bugfix/emit-moveToTrash-limit
Emit moveToTrash event only for the deleting user
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r--apps/files_trashbin/lib/Storage.php19
-rw-r--r--apps/files_trashbin/tests/StorageTest.php5
2 files changed, 16 insertions, 8 deletions
diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php
index 04105dda6ce..d109be4ea75 100644
--- a/apps/files_trashbin/lib/Storage.php
+++ b/apps/files_trashbin/lib/Storage.php
@@ -125,10 +125,21 @@ class Storage extends Wrapper {
* @return bool
*/
protected function shouldMoveToTrash($path) {
+ $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
+ $parts = explode('/', $normalized);
+ if (count($parts) < 4) {
+ return false;
+ }
// check if there is a app which want to disable the trash bin for this file
$fileId = $this->storage->getCache()->getId($path);
- $nodes = $this->rootFolder->getById($fileId);
+ $owner = $this->storage->getOwner($path);
+ if ($owner === false) {
+ $nodes = $this->rootFolder->getById($fileId);
+ } else {
+ $nodes = $this->rootFolder->getUserFolder($owner)->getById($fileId);
+ }
+
foreach ($nodes as $node) {
$event = $this->createMoveToTrashEvent($node);
$this->eventDispatcher->dispatch('OCA\Files_Trashbin::moveToTrash', $event);
@@ -137,12 +148,6 @@ class Storage extends Wrapper {
}
}
- $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
- $parts = explode('/', $normalized);
- if (count($parts) < 4) {
- return false;
- }
-
if ($parts[2] === 'files' && $this->userManager->userExists($parts[1])) {
return true;
}
diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php
index eff33f9b30c..3c660134d1c 100644
--- a/apps/files_trashbin/tests/StorageTest.php
+++ b/apps/files_trashbin/tests/StorageTest.php
@@ -36,6 +36,7 @@ use OCA\Files_Trashbin\Events\MoveToTrashEvent;
use OCA\Files_Trashbin\Storage;
use OCA\Files_Trashbin\Trash\ITrashManager;
use OCP\Files\Cache\ICache;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\ILogger;
@@ -545,12 +546,14 @@ class StorageTest extends \Test\TestCase {
$logger = $this->getMockBuilder(ILogger::class)->getMock();
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$rootFolder = $this->createMock(IRootFolder::class);
+ $userFolder = $this->createMock(Folder::class);
$node = $this->getMockBuilder(Node::class)->disableOriginalConstructor()->getMock();
$trashManager = $this->createMock(ITrashManager::class);
$event = $this->getMockBuilder(MoveToTrashEvent::class)->disableOriginalConstructor()->getMock();
$event->expects($this->any())->method('shouldMoveToTrashBin')->willReturn(!$appDisablesTrash);
- $rootFolder->expects($this->any())->method('getById')->with($fileID)->willReturn([$node]);
+ $userFolder->expects($this->any())->method('getById')->with($fileID)->willReturn([$node]);
+ $rootFolder->expects($this->any())->method('getUserFolder')->willReturn($userFolder);
$storage = $this->getMockBuilder(Storage::class)
->setConstructorArgs(