0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-02-11 03:29:29 +00:00
nextcloud_server/apps/dav/lib/Connector/Sabre/CachingTree.php
Daniel Kesselberg af6de04e9e
style: update codestyle for coding-standard 1.2.3
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
2024-08-25 19:34:58 +02:00

36 lines
845 B
PHP

<?php
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Connector\Sabre;
use Sabre\DAV\Tree;
class CachingTree extends Tree {
/**
* Store a node in the cache
*/
public function cacheNode(Node $node, ?string $path = null): void {
if (is_null($path)) {
$path = $node->getPath();
}
$this->cache[trim($path, '/')] = $node;
}
/**
* @param string $path
* @return void
*/
public function markDirty($path) {
// We don't care enough about sub-paths
// flushing the entire cache
$path = trim($path, '/');
foreach ($this->cache as $nodePath => $node) {
$nodePath = (string)$nodePath;
if ($path === '' || $nodePath == $path || str_starts_with($nodePath, $path . '/')) {
unset($this->cache[$nodePath]);
}
}
}
}