Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: don't use cached root info from shared cache if the watcher has …
…detected an update

Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Feb 7, 2025
commit 9e2ddea50535b54e389d0d3e0782475b52c27c7e
4 changes: 4 additions & 0 deletions apps/files_sharing/lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,8 @@ public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEnt
return null;
}
}

public function markRootChanged(): void {
$this->rootUnchanged = false;
}
}
5 changes: 5 additions & 0 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,12 @@
// 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) {

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType Note

Docblock-defined type OC\Files\Cache\Watcher for $this->watcher is always OC\Files\Cache\Watcher
$this->watcher->onUpdate([$cache, 'markRootChanged']);
}

return $this->watcher;
}
}
Expand Down
13 changes: 13 additions & 0 deletions lib/private/Files/Cache/Watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class Watcher implements IWatcher {
*/
protected $scanner;

/** @var callable[] */
protected $onUpdate = [];

/**
* @param \OC\Files\Storage\Storage $storage
*/
Expand Down Expand Up @@ -100,6 +103,9 @@ public function update($path, $cachedData) {
if ($this->cache instanceof Cache) {
$this->cache->correctFolderSize($path);
}
foreach ($this->onUpdate as $callback) {
$callback($path);
}
}

/**
Expand Down Expand Up @@ -130,4 +136,11 @@ public function cleanFolder($path) {
}
}
}

/**
* register a callback to be called whenever the watcher triggers and update
*/
public function onUpdate(callable $callback): void {
$this->onUpdate[] = $callback;
}
}
3 changes: 3 additions & 0 deletions lib/private/Files/Cache/Wrapper/JailWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ public function cleanFolder($path) {
$this->watcher->cleanFolder($this->getSourcePath($path));
}

public function onUpdate(callable $callback): void {
$this->watcher->onUpdate($callback);
}
}
Loading