mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix: don't use cached root info from shared cache if the watcher has detected an update
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
1211c03ee2
commit
2786ca579a
5 changed files with 31 additions and 0 deletions
|
|
@ -191,4 +191,8 @@ class Cache extends CacheJail {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function markRootChanged(): void {
|
||||
$this->rootUnchanged = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -441,7 +441,12 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
|
|||
// 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->onUpdate($cache->markRootChanged(...));
|
||||
}
|
||||
|
||||
return $this->watcher;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,4 +55,7 @@ class JailWatcher extends Watcher {
|
|||
$this->watcher->cleanFolder($this->getSourcePath($path));
|
||||
}
|
||||
|
||||
public function onUpdate(callable $callback): void {
|
||||
$this->watcher->onUpdate($callback);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue