diff options
author | Robin Appelman <robin@icewind.nl> | 2025-01-22 19:24:45 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2025-02-11 16:21:37 +0100 |
commit | 3bfcd8371b1567e139a37d467f80966f51490536 (patch) | |
tree | 13599377803978df27d5e2f1cb92c3ccfcf837e7 | |
parent | bec093203896fe6475679e135e9db3142c7da706 (diff) | |
download | nextcloud-server-backport/50324/stable30.tar.gz nextcloud-server-backport/50324/stable30.zip |
fix: don't use cached root info from shared cache if the watcher has detected an updatebackport/50324/stable30
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 5 | ||||
-rw-r--r-- | lib/private/Files/Cache/Watcher.php | 13 | ||||
-rw-r--r-- | lib/private/Files/Cache/Wrapper/JailWatcher.php | 3 |
4 files changed, 25 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 26a9bc7b524..de427ea8177 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -198,4 +198,8 @@ class Cache extends CacheJail { return null; } } + + public function markRootChanged(): void { + $this->rootUnchanged = false; + } } diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 3b42130c011..2ac157f7970 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -460,7 +460,12 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha // for shares from the home storage we can rely on the home storage to keep itself up to date // for other storages we need use the proper watcher if (!(str_starts_with($storageId, 'home::') || str_starts_with($storageId, 'object::user'))) { + $cache = $this->getCache(); $this->watcher = parent::getWatcher($path, $storage); + if ($cache instanceof Cache && $this->watcher instanceof Watcher) { + $this->watcher->onUpdate([$cache, 'markRootChanged']); + } + return $this->watcher; } } 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); + } } |