diff options
author | Robin Appelman <robin@icewind.nl> | 2025-02-11 16:01:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-11 16:01:37 +0100 |
commit | 53749e06fc3fe3a3de3cb4f9e84ef3c6be9bf648 (patch) | |
tree | 52c5e5476ba7d10340b3c7cb92ada1625bd63e03 /lib | |
parent | 5f423df9fd406c1a548a3cbbf67d147c82d1a068 (diff) | |
parent | 65a10f281d1c64109b6371c0d073ea061008d68e (diff) | |
download | nextcloud-server-53749e06fc3fe3a3de3cb4f9e84ef3c6be9bf648.tar.gz nextcloud-server-53749e06fc3fe3a3de3cb4f9e84ef3c6be9bf648.zip |
Merge pull request #50324 from nextcloud/shared-cache-watcher-update
fix: don't use cached root info from shared cache if the watcher has detected an update
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Cache/Watcher.php | 13 | ||||
-rw-r--r-- | lib/private/Files/Cache/Wrapper/JailWatcher.php | 3 | ||||
-rw-r--r-- | lib/public/Files/Cache/IWatcher.php | 6 |
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/private/Files/Cache/Watcher.php b/lib/private/Files/Cache/Watcher.php index 2e42b716695..b6c69dd7330 100644 --- a/lib/private/Files/Cache/Watcher.php +++ b/lib/private/Files/Cache/Watcher.php @@ -33,6 +33,9 @@ class Watcher implements IWatcher { */ protected $scanner; + /** @var callable[] */ + protected $onUpdate = []; + /** * @param \OC\Files\Storage\Storage $storage */ @@ -100,6 +103,9 @@ class Watcher implements IWatcher { if ($this->cache instanceof Cache) { $this->cache->correctFolderSize($path); } + foreach ($this->onUpdate as $callback) { + $callback($path); + } } /** @@ -130,4 +136,11 @@ class Watcher implements IWatcher { } } } + + /** + * register a callback to be called whenever the watcher triggers and update + */ + public function onUpdate(callable $callback): void { + $this->onUpdate[] = $callback; + } } diff --git a/lib/private/Files/Cache/Wrapper/JailWatcher.php b/lib/private/Files/Cache/Wrapper/JailWatcher.php index 9bd7da57233..b1ae516654a 100644 --- a/lib/private/Files/Cache/Wrapper/JailWatcher.php +++ b/lib/private/Files/Cache/Wrapper/JailWatcher.php @@ -55,4 +55,7 @@ class JailWatcher extends Watcher { $this->watcher->cleanFolder($this->getSourcePath($path)); } + public function onUpdate(callable $callback): void { + $this->watcher->onUpdate($callback); + } } diff --git a/lib/public/Files/Cache/IWatcher.php b/lib/public/Files/Cache/IWatcher.php index 75ab14f85c2..62b90f672c6 100644 --- a/lib/public/Files/Cache/IWatcher.php +++ b/lib/public/Files/Cache/IWatcher.php @@ -76,4 +76,10 @@ interface IWatcher { * @since 9.0.0 */ public function cleanFolder($path); + + /** + * register a callback to be called whenever the watcher triggers and update + * @since 31.0.0 + */ + public function onUpdate(callable $callback): void; } |