Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
'OCP\\Files\\Events\\BeforeFileScannedEvent' => $baseDir . '/lib/public/Files/Events/BeforeFileScannedEvent.php',
'OCP\\Files\\Events\\BeforeFileSystemSetupEvent' => $baseDir . '/lib/public/Files/Events/BeforeFileSystemSetupEvent.php',
'OCP\\Files\\Events\\BeforeFolderScannedEvent' => $baseDir . '/lib/public/Files/Events/BeforeFolderScannedEvent.php',
'OCP\\Files\\Events\\BeforeRemotePropfindEvent' => $baseDir . '/lib/public/Files/Events/BeforeRemotePropfindEvent.php',
'OCP\\Files\\Events\\BeforeZipCreatedEvent' => $baseDir . '/lib/public/Files/Events/BeforeZipCreatedEvent.php',
'OCP\\Files\\Events\\FileCacheUpdated' => $baseDir . '/lib/public/Files/Events/FileCacheUpdated.php',
'OCP\\Files\\Events\\FileScannedEvent' => $baseDir . '/lib/public/Files/Events/FileScannedEvent.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Files\\Events\\BeforeFileScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFileScannedEvent.php',
'OCP\\Files\\Events\\BeforeFileSystemSetupEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFileSystemSetupEvent.php',
'OCP\\Files\\Events\\BeforeFolderScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFolderScannedEvent.php',
'OCP\\Files\\Events\\BeforeRemotePropfindEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeRemotePropfindEvent.php',
'OCP\\Files\\Events\\BeforeZipCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeZipCreatedEvent.php',
'OCP\\Files\\Events\\FileCacheUpdated' => __DIR__ . '/../../..' . '/lib/public/Files/Events/FileCacheUpdated.php',
'OCP\\Files\\Events\\FileScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/FileScannedEvent.php',
Expand Down
34 changes: 32 additions & 2 deletions lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use OCP\AppFramework\Http;
use OCP\Constants;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\BeforeRemotePropfindEvent;
use OCP\Files\FileInfo;
use OCP\Files\ForbiddenException;
use OCP\Files\IMimeTypeDetector;
Expand Down Expand Up @@ -232,6 +234,34 @@ public function opendir(string $path) {
return false;
}

/**
* @return array<string>
*/
protected function getPropfindProperties(): array {
$event = new BeforeRemotePropfindEvent(self::PROPFIND_PROPS);
Server::get(IEventDispatcher::class)->dispatchTyped($event);
return $event->getProperties();
}

/**
* Get property value from cached PROPFIND response.
* For accessing app-specific properties not included in getMetaData().
*
* @param string $path
* @param string $propertyName
* @return mixed
*/
public function getPropfindPropertyValue(string $path, string $propertyName): mixed {
$path = $this->cleanPath($path);
$propfindResponse = $this->statCache->get($path);

if (!is_array($propfindResponse)) {
return null;
}

return $propfindResponse[$propertyName] ?? null;
}

/**
* Propfind call with cache handling.
*
Expand All @@ -254,7 +284,7 @@ protected function propfind(string $path): array|false {
try {
$response = $this->client->propFind(
$this->encodePath($path),
self::PROPFIND_PROPS
$this->getPropfindProperties()
);
$this->statCache->set($path, $response);
} catch (ClientHttpException $e) {
Expand Down Expand Up @@ -818,7 +848,7 @@ public function getDirectoryContent(string $directory): \Traversable {
try {
$responses = $this->client->propFind(
$this->encodePath($directory),
self::PROPFIND_PROPS,
$this->getPropfindProperties(),
1
);

Expand Down
39 changes: 39 additions & 0 deletions lib/public/Files/Events/BeforeRemotePropfindEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCP\Files\Events;

use OCP\EventDispatcher\Event;

/**
* @since 33.0.0
*/
class BeforeRemotePropfindEvent extends Event {
public function __construct(
private array $properties,
) {
parent::__construct();
}

/**
* @return array<string>
* @since 33.0.0
*/
public function getProperties(): array {
return $this->properties;
}

/**
* @param array<string> $properties
* @since 33.0.0
*/
public function addProperties(array $properties): void {
$this->properties = [...$this->properties, ...$properties];
}
}
Loading