Skip to content

Commit 88f35d5

Browse files
committed
rename cache event to follow new naming standards
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 23fb497 commit 88f35d5

8 files changed

Lines changed: 103 additions & 17 deletions

File tree

lib/composer/composer/autoload_classmap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,10 @@
218218
'OCP\\Federation\\ICloudIdManager' => $baseDir . '/lib/public/Federation/ICloudIdManager.php',
219219
'OCP\\Files' => $baseDir . '/lib/public/Files.php',
220220
'OCP\\Files\\AlreadyExistsException' => $baseDir . '/lib/public/Files/AlreadyExistsException.php',
221+
'OCP\\Files\\Cache\\CacheEntryInsertedEvent' => $baseDir . '/lib/public/Files/Cache/CacheEntryInsertedEvent.php',
222+
'OCP\\Files\\Cache\\CacheEntryRemovedEvent' => $baseDir . '/lib/public/Files/Cache/CacheEntryRemovedEvent.php',
223+
'OCP\\Files\\Cache\\CacheEntryUpdatedEvent' => $baseDir . '/lib/public/Files/Cache/CacheEntryUpdatedEvent.php',
221224
'OCP\\Files\\Cache\\CacheInsertEvent' => $baseDir . '/lib/public/Files/Cache/CacheInsertEvent.php',
222-
'OCP\\Files\\Cache\\CacheRemoveEvent' => $baseDir . '/lib/public/Files/Cache/CacheRemoveEvent.php',
223225
'OCP\\Files\\Cache\\CacheUpdateEvent' => $baseDir . '/lib/public/Files/Cache/CacheUpdateEvent.php',
224226
'OCP\\Files\\Cache\\ICache' => $baseDir . '/lib/public/Files/Cache/ICache.php',
225227
'OCP\\Files\\Cache\\ICacheEntry' => $baseDir . '/lib/public/Files/Cache/ICacheEntry.php',

lib/composer/composer/autoload_static.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
247247
'OCP\\Federation\\ICloudIdManager' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudIdManager.php',
248248
'OCP\\Files' => __DIR__ . '/../../..' . '/lib/public/Files.php',
249249
'OCP\\Files\\AlreadyExistsException' => __DIR__ . '/../../..' . '/lib/public/Files/AlreadyExistsException.php',
250+
'OCP\\Files\\Cache\\CacheEntryInsertedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheEntryInsertedEvent.php',
251+
'OCP\\Files\\Cache\\CacheEntryRemovedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheEntryRemovedEvent.php',
252+
'OCP\\Files\\Cache\\CacheEntryUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheEntryUpdatedEvent.php',
250253
'OCP\\Files\\Cache\\CacheInsertEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheInsertEvent.php',
251-
'OCP\\Files\\Cache\\CacheRemoveEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheRemoveEvent.php',
252254
'OCP\\Files\\Cache\\CacheUpdateEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheUpdateEvent.php',
253255
'OCP\\Files\\Cache\\ICache' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICache.php',
254256
'OCP\\Files\\Cache\\ICacheEntry' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICacheEntry.php',

lib/private/Files/Cache/Cache.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141
use Doctrine\DBAL\Driver\Statement;
4242
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
4343
use OCP\DB\QueryBuilder\IQueryBuilder;
44+
use OCP\EventDispatcher\IEventDispatcher;
45+
use OCP\Files\Cache\CacheEntryInsertedEvent;
46+
use OCP\Files\Cache\CacheEntryUpdatedEvent;
4447
use OCP\Files\Cache\CacheInsertEvent;
45-
use OCP\Files\Cache\CacheRemoveEvent;
48+
use OCP\Files\Cache\CacheEntryRemovedEvent;
4649
use OCP\Files\Cache\CacheUpdateEvent;
4750
use OCP\Files\Cache\ICache;
4851
use OCP\Files\Cache\ICacheEntry;
@@ -92,6 +95,9 @@ class Cache implements ICache {
9295
*/
9396
protected $connection;
9497

98+
/**
99+
* @var IEventDispatcher
100+
*/
95101
protected $eventDispatcher;
96102

97103
/** @var QuerySearchHelper */
@@ -110,7 +116,7 @@ public function __construct(IStorage $storage) {
110116
$this->storageCache = new Storage($storage);
111117
$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
112118
$this->connection = \OC::$server->getDatabaseConnection();
113-
$this->eventDispatcher = \OC::$server->getEventDispatcher();
119+
$this->eventDispatcher = \OC::$server->get(IEventDispatcher::class);
114120
$this->querySearchHelper = new QuerySearchHelper($this->mimetypeLoader);
115121
}
116122

@@ -310,7 +316,9 @@ public function insert($file, array $data) {
310316
$query->execute();
311317
}
312318

313-
$this->eventDispatcher->dispatch(CacheInsertEvent::class, new CacheInsertEvent($this->storage, $file, $fileId, $storageId));
319+
$event = new CacheEntryInsertedEvent($this->storage, $file, $fileId, $storageId);
320+
$this->eventDispatcher->dispatch(CacheInsertEvent::class, $event);
321+
$this->eventDispatcher->dispatchTyped($event);
314322
return $fileId;
315323
}
316324
} catch (UniqueConstraintViolationException $e) {
@@ -401,7 +409,9 @@ public function update($id, array $data) {
401409
$path = $this->getPathById($id);
402410
// path can still be null if the file doesn't exist
403411
if ($path !== null) {
404-
$this->eventDispatcher->dispatch(CacheUpdateEvent::class, new CacheUpdateEvent($this->storage, $path, $id, $this->getNumericStorageId()));
412+
$event = new CacheEntryUpdatedEvent($this->storage, $path, $id, $this->getNumericStorageId());
413+
$this->eventDispatcher->dispatch(CacheUpdateEvent::class, $event);
414+
$this->eventDispatcher->dispatchTyped($event);
405415
}
406416
}
407417

@@ -539,7 +549,7 @@ public function remove($file) {
539549
$this->removeChildren($entry);
540550
}
541551

542-
$this->eventDispatcher->dispatch(CacheRemoveEvent::class, new CacheRemoveEvent($this->storage, $entry->getPath(), $entry->getId(), $this->getNumericStorageId()));
552+
$this->eventDispatcher->dispatch(CacheEntryRemovedEvent::class, new CacheEntryRemovedEvent($this->storage, $entry->getPath(), $entry->getId(), $this->getNumericStorageId()));
543553
}
544554
}
545555

@@ -683,10 +693,14 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
683693
$this->connection->commit();
684694

685695
if ($sourceCache->getNumericStorageId() !== $this->getNumericStorageId()) {
686-
$this->eventDispatcher->dispatch(CacheRemoveEvent::class, new CacheRemoveEvent($this->storage, $sourcePath, $sourceId, $sourceCache->getNumericStorageId()));
687-
$this->eventDispatcher->dispatch(CacheInsertEvent::class, new CacheInsertEvent($this->storage, $targetPath, $sourceId, $this->getNumericStorageId()));
696+
$this->eventDispatcher->dispatchTyped(new CacheEntryRemovedEvent($this->storage, $sourcePath, $sourceId, $sourceCache->getNumericStorageId()));
697+
$event = new CacheEntryInsertedEvent($this->storage, $targetPath, $sourceId, $this->getNumericStorageId());
698+
$this->eventDispatcher->dispatch(CacheInsertEvent::class, $event);
699+
$this->eventDispatcher->dispatchTyped($event);
688700
} else {
689-
$this->eventDispatcher->dispatch(CacheUpdateEvent::class, new CacheUpdateEvent($this->storage, $targetPath, $sourceId, $this->getNumericStorageId()));
701+
$event = new CacheEntryUpdatedEvent($this->storage, $targetPath, $sourceId, $this->getNumericStorageId());
702+
$this->eventDispatcher->dispatch(CacheUpdateEvent::class, $event);
703+
$this->eventDispatcher->dispatchTyped($event);
690704
}
691705
} else {
692706
$this->moveFromCacheFallback($sourceCache, $sourcePath, $targetPath);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCP\Files\Cache;
25+
26+
27+
use OC\Files\Cache\AbstractCacheEvent;
28+
29+
/**
30+
* Event for when an existing entry in the cache gets inserted
31+
*
32+
* @since 21.0.0
33+
*/
34+
class CacheEntryInsertedEvent extends AbstractCacheEvent implements ICacheEvent {
35+
}

lib/public/Files/Cache/CacheRemoveEvent.php renamed to lib/public/Files/Cache/CacheEntryRemovedEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
*
3131
* @since 21.0.0
3232
*/
33-
class CacheRemoveEvent extends AbstractCacheEvent {
33+
class CacheEntryRemovedEvent extends AbstractCacheEvent implements ICacheEvent {
3434
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCP\Files\Cache;
25+
26+
27+
use OC\Files\Cache\AbstractCacheEvent;
28+
29+
/**
30+
* Event for when an existing entry in the cache gets updated
31+
*
32+
* @since 21.0.0
33+
*/
34+
class CacheEntryUpdatedEvent extends AbstractCacheEvent implements ICacheEvent {
35+
}

lib/public/Files/Cache/CacheInsertEvent.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626

2727
namespace OCP\Files\Cache;
2828

29-
use OC\Files\Cache\AbstractCacheEvent;
30-
3129
/**
3230
* Event for when a new entry gets added to the cache
3331
*
3432
* @since 16.0.0
33+
* @deprecated 21.0.0 use CacheEntryInsertedEvent instead
3534
*/
36-
class CacheInsertEvent extends AbstractCacheEvent {
35+
class CacheInsertEvent extends CacheEntryInsertedEvent {
3736
}

lib/public/Files/Cache/CacheUpdateEvent.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626

2727
namespace OCP\Files\Cache;
2828

29-
use OC\Files\Cache\AbstractCacheEvent;
30-
3129
/**
3230
* Event for when an existing entry in the cache gets updated
3331
*
3432
* @since 16.0.0
33+
* @deprecated 21.0.0 use CacheEntryUpdatedEvent instead
3534
*/
36-
class CacheUpdateEvent extends AbstractCacheEvent {
35+
class CacheUpdateEvent extends CacheEntryUpdatedEvent {
3736
}

0 commit comments

Comments
 (0)