Skip to content

Commit e405549

Browse files
feat: cache permission info of files, folders while open dir
Signed-off-by: Luka Trovic <[email protected]>
1 parent 7d9d99d commit e405549

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/private/Files/Storage/DAV.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class DAV extends Common {
8686
protected $client;
8787
/** @var ArrayCache */
8888
protected $statCache;
89+
/** @var ArrayCache */
90+
protected $propfindCache;
8991
/** @var IClientService */
9092
protected $httpClientService;
9193
/** @var ICertificateManager */
@@ -99,6 +101,7 @@ class DAV extends Common {
99101
*/
100102
public function __construct($params) {
101103
$this->statCache = new ArrayCache();
104+
$this->propfindCache = new ArrayCache();
102105
$this->httpClientService = \OC::$server->getHTTPClientService();
103106
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
104107
$host = $params['host'];
@@ -235,7 +238,16 @@ public function opendir($path) {
235238
try {
236239
$response = $this->client->propFind(
237240
$this->encodePath($path),
238-
['{DAV:}getetag'],
241+
[
242+
'{DAV:}getlastmodified',
243+
'{DAV:}getcontentlength',
244+
'{DAV:}getcontenttype',
245+
'{http://owncloud.org/ns}permissions',
246+
'{http://open-collaboration-services.org/ns}share-permissions',
247+
'{DAV:}resourcetype',
248+
'{DAV:}getetag',
249+
'{DAV:}quota-available-bytes',
250+
],
239251
1
240252
);
241253
if ($response === false) {
@@ -254,7 +266,9 @@ public function opendir($path) {
254266
if (!$this->statCache->hasKey($path)) {
255267
$this->statCache->set($file, true);
256268
}
269+
$fileDetail = $response[$file];
257270
$file = basename($file);
271+
$this->propfindCache->set($file, $fileDetail);
258272
$content[] = $file;
259273
}
260274
return IteratorDirectory::wrap($content);
@@ -278,6 +292,10 @@ public function opendir($path) {
278292
*/
279293
protected function propfind($path) {
280294
$path = $this->cleanPath($path);
295+
$propfindCacheResponse = $this->propfindCache->get($path);
296+
if (!is_null($propfindCacheResponse)) {
297+
return $propfindCacheResponse;
298+
}
281299
$cachedResponse = $this->statCache->get($path);
282300
// we either don't know it, or we know it exists but need more details
283301
if (is_null($cachedResponse) || $cachedResponse === true) {

0 commit comments

Comments
 (0)