diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 7 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 7 | ||||
-rw-r--r-- | lib/l10n/sr.js | 1 | ||||
-rw-r--r-- | lib/l10n/sr.json | 1 | ||||
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 16 | ||||
-rw-r--r-- | lib/private/Accounts/Hooks.php | 8 | ||||
-rw-r--r-- | lib/private/Files/Utils/Scanner.php | 56 | ||||
-rw-r--r-- | lib/public/Files/Events/BeforeFileScannedEvent.php | 56 | ||||
-rw-r--r-- | lib/public/Files/Events/BeforeFolderScannedEvent.php | 56 | ||||
-rw-r--r-- | lib/public/Files/Events/FileCacheUpdated.php | 70 | ||||
-rw-r--r-- | lib/public/Files/Events/FileScannedEvent.php | 56 | ||||
-rw-r--r-- | lib/public/Files/Events/FolderScannedEvent.php | 56 | ||||
-rw-r--r-- | lib/public/Files/Events/NodeAddedToCache.php | 70 | ||||
-rw-r--r-- | lib/public/Files/Events/NodeRemovedFromCache.php | 70 |
14 files changed, 502 insertions, 28 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index bfc024e5851..069102baaad 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -220,6 +220,13 @@ return array( 'OCP\\Files\\Config\\IUserMountCache' => $baseDir . '/lib/public/Files/Config/IUserMountCache.php', 'OCP\\Files\\EmptyFileNameException' => $baseDir . '/lib/public/Files/EmptyFileNameException.php', 'OCP\\Files\\EntityTooLargeException' => $baseDir . '/lib/public/Files/EntityTooLargeException.php', + 'OCP\\Files\\Events\\BeforeFileScannedEvent' => $baseDir . '/lib/public/Files/Events/BeforeFileScannedEvent.php', + 'OCP\\Files\\Events\\BeforeFolderScannedEvent' => $baseDir . '/lib/public/Files/Events/BeforeFolderScannedEvent.php', + 'OCP\\Files\\Events\\FileCacheUpdated' => $baseDir . '/lib/public/Files/Events/FileCacheUpdated.php', + 'OCP\\Files\\Events\\FileScannedEvent' => $baseDir . '/lib/public/Files/Events/FileScannedEvent.php', + 'OCP\\Files\\Events\\FolderScannedEvent' => $baseDir . '/lib/public/Files/Events/FolderScannedEvent.php', + 'OCP\\Files\\Events\\NodeAddedToCache' => $baseDir . '/lib/public/Files/Events/NodeAddedToCache.php', + 'OCP\\Files\\Events\\NodeRemovedFromCache' => $baseDir . '/lib/public/Files/Events/NodeRemovedFromCache.php', 'OCP\\Files\\File' => $baseDir . '/lib/public/Files/File.php', 'OCP\\Files\\FileInfo' => $baseDir . '/lib/public/Files/FileInfo.php', 'OCP\\Files\\FileNameTooLongException' => $baseDir . '/lib/public/Files/FileNameTooLongException.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 6fe4529c295..b12636e8e08 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -249,6 +249,13 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Files\\Config\\IUserMountCache' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IUserMountCache.php', 'OCP\\Files\\EmptyFileNameException' => __DIR__ . '/../../..' . '/lib/public/Files/EmptyFileNameException.php', 'OCP\\Files\\EntityTooLargeException' => __DIR__ . '/../../..' . '/lib/public/Files/EntityTooLargeException.php', + 'OCP\\Files\\Events\\BeforeFileScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFileScannedEvent.php', + 'OCP\\Files\\Events\\BeforeFolderScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFolderScannedEvent.php', + 'OCP\\Files\\Events\\FileCacheUpdated' => __DIR__ . '/../../..' . '/lib/public/Files/Events/FileCacheUpdated.php', + 'OCP\\Files\\Events\\FileScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/FileScannedEvent.php', + 'OCP\\Files\\Events\\FolderScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/FolderScannedEvent.php', + 'OCP\\Files\\Events\\NodeAddedToCache' => __DIR__ . '/../../..' . '/lib/public/Files/Events/NodeAddedToCache.php', + 'OCP\\Files\\Events\\NodeRemovedFromCache' => __DIR__ . '/../../..' . '/lib/public/Files/Events/NodeRemovedFromCache.php', 'OCP\\Files\\File' => __DIR__ . '/../../..' . '/lib/public/Files/File.php', 'OCP\\Files\\FileInfo' => __DIR__ . '/../../..' . '/lib/public/Files/FileInfo.php', 'OCP\\Files\\FileNameTooLongException' => __DIR__ . '/../../..' . '/lib/public/Files/FileNameTooLongException.php', diff --git a/lib/l10n/sr.js b/lib/l10n/sr.js index 2e26ae3fd56..1e1ec2c9a2b 100644 --- a/lib/l10n/sr.js +++ b/lib/l10n/sr.js @@ -174,6 +174,7 @@ OC.L10N.register( "A valid username must be provided" : "Морате унети исправно корисничко име", "Username contains whitespace at the beginning or at the end" : "Корисничко име садржи белине на почетку или на крају", "Username must not consist of dots only" : "Корисничко име не могу бити само тачке", + "Username is invalid because files already exist for this user" : "Корисничко име није исправно пошто већ постоје фајлови за овог корисника", "A valid password must be provided" : "Морате унети исправну лозинку", "The username is already being used" : "Корисничко име се већ користи", "Could not create user" : "Не могу да направим корисника", diff --git a/lib/l10n/sr.json b/lib/l10n/sr.json index 4a4e3b95309..5de5b79988c 100644 --- a/lib/l10n/sr.json +++ b/lib/l10n/sr.json @@ -172,6 +172,7 @@ "A valid username must be provided" : "Морате унети исправно корисничко име", "Username contains whitespace at the beginning or at the end" : "Корисничко име садржи белине на почетку или на крају", "Username must not consist of dots only" : "Корисничко име не могу бити само тачке", + "Username is invalid because files already exist for this user" : "Корисничко име није исправно пошто већ постоје фајлови за овог корисника", "A valid password must be provided" : "Морате унети исправну лозинку", "The username is already being used" : "Корисничко име се већ користи", "Could not create user" : "Не могу да направим корисника", diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index f1607b1a1ef..225d076ca37 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -1,4 +1,5 @@ <?php + /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, Björn Schießle @@ -33,9 +34,12 @@ use OCP\Accounts\IAccount; use OCP\Accounts\IAccountManager; use OCP\BackgroundJob\IJobList; use OCP\IDBConnection; +use OCP\ILogger; use OCP\IUser; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; +use function json_decode; +use function json_last_error; /** * Class AccountManager @@ -59,6 +63,9 @@ class AccountManager implements IAccountManager { /** @var IJobList */ private $jobList; + /** @var ILogger */ + private $logger; + /** * AccountManager constructor. * @@ -68,10 +75,12 @@ class AccountManager implements IAccountManager { */ public function __construct(IDBConnection $connection, EventDispatcherInterface $eventDispatcher, - IJobList $jobList) { + IJobList $jobList, + ILogger $logger) { $this->connection = $connection; $this->eventDispatcher = $eventDispatcher; $this->jobList = $jobList; + $this->logger = $logger; } /** @@ -137,6 +146,11 @@ class AccountManager implements IAccountManager { } $userDataArray = json_decode($result[0]['data'], true); + $jsonError = json_last_error(); + if ($userDataArray === null || $jsonError !== JSON_ERROR_NONE) { + $this->logger->critical("User data of $uid contained invalid JSON (error $jsonError), hence falling back to a default user record"); + return $this->buildDefaultUserRecord($user); + } $userDataArray = $this->addMissingDefaultValues($userDataArray); diff --git a/lib/private/Accounts/Hooks.php b/lib/private/Accounts/Hooks.php index 5c6826a6f9e..268f9d82753 100644 --- a/lib/private/Accounts/Hooks.php +++ b/lib/private/Accounts/Hooks.php @@ -87,12 +87,8 @@ class Hooks { * @return AccountManager */ protected function getAccountManager() { - if (is_null($this->accountManager)) { - $this->accountManager = new AccountManager( - \OC::$server->getDatabaseConnection(), - \OC::$server->getEventDispatcher(), - \OC::$server->getJobList() - ); + if ($this->accountManager === null) { + $this->accountManager = \OC::$server->query(AccountManager::class); } return $this->accountManager; } diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 45194b57cbf..53712d28171 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -36,9 +36,18 @@ use OC\ForbiddenException; use OC\Hooks\PublicEmitter; use OC\Lock\DBLockingProvider; use OCA\Files_Sharing\SharedStorage; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\Events\BeforeFileScannedEvent; +use OCP\Files\Events\BeforeFolderScannedEvent; +use OCP\Files\Events\NodeAddedToCache; +use OCP\Files\Events\FileCacheUpdated; +use OCP\Files\Events\NodeRemovedFromCache; +use OCP\Files\Events\FileScannedEvent; +use OCP\Files\Events\FolderScannedEvent; use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; +use OCP\IDBConnection; use OCP\ILogger; /** @@ -53,19 +62,16 @@ use OCP\ILogger; class Scanner extends PublicEmitter { const MAX_ENTRIES_TO_COMMIT = 10000; - /** - * @var string $user - */ + /** @var string $user */ private $user; - /** - * @var \OCP\IDBConnection - */ + /** @var IDBConnection */ protected $db; - /** - * @var ILogger - */ + /** @var IEventDispatcher */ + private $dispatcher; + + /** @var ILogger */ protected $logger; /** @@ -84,13 +90,15 @@ class Scanner extends PublicEmitter { /** * @param string $user - * @param \OCP\IDBConnection $db + * @param IDBConnection|null $db + * @param IEventDispatcher $dispatcher * @param ILogger $logger */ - public function __construct($user, $db, ILogger $logger) { - $this->logger = $logger; + public function __construct($user, $db, IEventDispatcher $dispatcher, ILogger $logger) { $this->user = $user; $this->db = $db; + $this->dispatcher = $dispatcher; + $this->logger = $logger; // when DB locking is used, no DB transactions will be used $this->useTransaction = !(\OC::$server->getLockingProvider() instanceof DBLockingProvider); } @@ -121,18 +129,21 @@ class Scanner extends PublicEmitter { */ protected function attachListener($mount) { $scanner = $mount->getStorage()->getScanner(); - $emitter = $this; - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount, $emitter) { - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path)); + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount) { + $this->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path)); + $this->dispatcher->dispatchTyped(new BeforeFileScannedEvent($mount->getMountPoint() . $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) { - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount) { + $this->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); + $this->dispatcher->dispatchTyped(new BeforeFolderScannedEvent($mount->getMountPoint() . $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) { - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount) { + $this->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); + $this->dispatcher->dispatchTyped(new FileScannedEvent($mount->getMountPoint() . $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) { - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount) { + $this->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); + $this->dispatcher->dispatchTyped(new FolderScannedEvent($mount->getMountPoint() . $path)); }); } @@ -225,12 +236,15 @@ class Scanner extends PublicEmitter { $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { $this->postProcessEntry($storage, $path); + $this->dispatcher->dispatchTyped(new NodeRemovedFromCache($storage, $path)); }); $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { $this->postProcessEntry($storage, $path); + $this->dispatcher->dispatchTyped(new FileCacheUpdated($storage, $path)); }); $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { $this->postProcessEntry($storage, $path); + $this->dispatcher->dispatchTyped(new NodeAddedToCache($storage, $path)); }); if (!$storage->file_exists($relativePath)) { diff --git a/lib/public/Files/Events/BeforeFileScannedEvent.php b/lib/public/Files/Events/BeforeFileScannedEvent.php new file mode 100644 index 00000000000..3f8dca2b333 --- /dev/null +++ b/lib/public/Files/Events/BeforeFileScannedEvent.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 OCP\Files\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class BeforeFileScannedEvent extends Event { + + /** @var string */ + private $absolutePath; + + /** + * @param string $absolutePath + * + * @since 18.0.0 + */ + public function __construct(string $absolutePath) { + parent::__construct(); + $this->absolutePath = $absolutePath; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getAbsolutePath(): string { + return $this->absolutePath; + } + +} diff --git a/lib/public/Files/Events/BeforeFolderScannedEvent.php b/lib/public/Files/Events/BeforeFolderScannedEvent.php new file mode 100644 index 00000000000..a253974c21e --- /dev/null +++ b/lib/public/Files/Events/BeforeFolderScannedEvent.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 OCP\Files\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class BeforeFolderScannedEvent extends Event { + + /** @var string */ + private $absolutePath; + + /** + * @param string $absolutePath + * + * @since 18.0.0 + */ + public function __construct(string $absolutePath) { + parent::__construct(); + $this->absolutePath = $absolutePath; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getAbsolutePath(): string { + return $this->absolutePath; + } + +} diff --git a/lib/public/Files/Events/FileCacheUpdated.php b/lib/public/Files/Events/FileCacheUpdated.php new file mode 100644 index 00000000000..c0f4771ae52 --- /dev/null +++ b/lib/public/Files/Events/FileCacheUpdated.php @@ -0,0 +1,70 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 OCP\Files\Events; + +use OCP\EventDispatcher\Event; +use OCP\Files\Storage\IStorage; + +/** + * @since 18.0.0 + */ +class FileCacheUpdated extends Event { + + /** @var IStorage */ + private $storage; + + /** @var string */ + private $path; + + /** + * @param IStorage $storage + * @param string $path + * @since 18.0.0 + */ + public function __construct(IStorage $storage, + string $path) { + parent::__construct(); + $this->storage = $storage; + $this->path = $path; + } + + /** + * @return IStorage + * @since 18.0.0 + */ + public function getStorage(): IStorage { + return $this->storage; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getPath(): string { + return $this->path; + } + +} diff --git a/lib/public/Files/Events/FileScannedEvent.php b/lib/public/Files/Events/FileScannedEvent.php new file mode 100644 index 00000000000..a93189225e4 --- /dev/null +++ b/lib/public/Files/Events/FileScannedEvent.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 OCP\Files\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class FileScannedEvent extends Event { + + /** @var string */ + private $absolutePath; + + /** + * @param string $absolutePath + * + * @since 18.0.0 + */ + public function __construct(string $absolutePath) { + parent::__construct(); + $this->absolutePath = $absolutePath; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getAbsolutePath(): string { + return $this->absolutePath; + } + +} diff --git a/lib/public/Files/Events/FolderScannedEvent.php b/lib/public/Files/Events/FolderScannedEvent.php new file mode 100644 index 00000000000..d1667cd8bc6 --- /dev/null +++ b/lib/public/Files/Events/FolderScannedEvent.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 OCP\Files\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class FolderScannedEvent extends Event { + + /** @var string */ + private $absolutePath; + + /** + * @param string $absolutePath + * + * @since 18.0.0 + */ + public function __construct(string $absolutePath) { + parent::__construct(); + $this->absolutePath = $absolutePath; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getAbsolutePath(): string { + return $this->absolutePath; + } + +} diff --git a/lib/public/Files/Events/NodeAddedToCache.php b/lib/public/Files/Events/NodeAddedToCache.php new file mode 100644 index 00000000000..966d42a384e --- /dev/null +++ b/lib/public/Files/Events/NodeAddedToCache.php @@ -0,0 +1,70 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 OCP\Files\Events; + +use OCP\EventDispatcher\Event; +use OCP\Files\Storage\IStorage; + +/** + * @since 18.0.0 + */ +class NodeAddedToCache extends Event { + + /** @var IStorage */ + private $storage; + + /** @var string */ + private $path; + + /** + * @param IStorage $storage + * @param string $path + * @since 18.0.0 + */ + public function __construct(IStorage $storage, + string $path) { + parent::__construct(); + $this->storage = $storage; + $this->path = $path; + } + + /** + * @return IStorage + * @since 18.0.0 + */ + public function getStorage(): IStorage { + return $this->storage; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getPath(): string { + return $this->path; + } + +} diff --git a/lib/public/Files/Events/NodeRemovedFromCache.php b/lib/public/Files/Events/NodeRemovedFromCache.php new file mode 100644 index 00000000000..c8d84624a8b --- /dev/null +++ b/lib/public/Files/Events/NodeRemovedFromCache.php @@ -0,0 +1,70 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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 OCP\Files\Events; + +use OCP\EventDispatcher\Event; +use OCP\Files\Storage\IStorage; + +/** + * @since 18.0.0 + */ +class NodeRemovedFromCache extends Event { + + /** @var IStorage */ + private $storage; + + /** @var string */ + private $path; + + /** + * @param IStorage $storage + * @param string $path + * @since 18.0.0 + */ + public function __construct(IStorage $storage, + string $path) { + parent::__construct(); + $this->storage = $storage; + $this->path = $path; + } + + /** + * @return IStorage + * @since 18.0.0 + */ + public function getStorage(): IStorage { + return $this->storage; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getPath(): string { + return $this->path; + } + +} |